summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Nibade <dnibade@nvidia.com>2016-12-27 05:01:00 -0500
committerDeepak Nibade <dnibade@nvidia.com>2016-12-27 05:35:06 -0500
commit7a81883a0d70c3a43ad2841ac235f6dc344c60fb (patch)
tree92923d2efccf90d1961071fa9acde59178a0d688
parent505b442551a2e27aa3bc9e608c5a2bc9fccecbc4 (diff)
parent2aa3c85f8e82b3c07c39e677663abd3687c1822a (diff)
Merge remote-tracking branch 'remotes/origin/dev/merge-nvgpu-t18x-into-nvgpu' into dev-kernel
Merge T186 - gp10b/gp106 code into common nvgpu repo Bug 200266498 Change-Id: Ibf100ee38010cbed85c149b69b99147256f9a005 Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/Makefile.nvgpu-t18x75
-rw-r--r--drivers/gpu/nvgpu/acr_t18x.h20
-rw-r--r--drivers/gpu/nvgpu/clk/clk.c529
-rw-r--r--drivers/gpu/nvgpu/clk/clk.h120
-rw-r--r--drivers/gpu/nvgpu/clk/clk_arb.c1548
-rw-r--r--drivers/gpu/nvgpu/clk/clk_arb.h71
-rw-r--r--drivers/gpu/nvgpu/clk/clk_domain.c1113
-rw-r--r--drivers/gpu/nvgpu/clk/clk_domain.h116
-rw-r--r--drivers/gpu/nvgpu/clk/clk_fll.c440
-rw-r--r--drivers/gpu/nvgpu/clk/clk_fll.h68
-rw-r--r--drivers/gpu/nvgpu/clk/clk_freq_controller.c454
-rw-r--r--drivers/gpu/nvgpu/clk/clk_freq_controller.h74
-rw-r--r--drivers/gpu/nvgpu/clk/clk_mclk.c2499
-rw-r--r--drivers/gpu/nvgpu/clk/clk_mclk.h52
-rw-r--r--drivers/gpu/nvgpu/clk/clk_prog.c1098
-rw-r--r--drivers/gpu/nvgpu/clk/clk_prog.h90
-rw-r--r--drivers/gpu/nvgpu/clk/clk_vf_point.c418
-rw-r--r--drivers/gpu/nvgpu/clk/clk_vf_point.h74
-rw-r--r--drivers/gpu/nvgpu/clk/clk_vin.c466
-rw-r--r--drivers/gpu/nvgpu/clk/clk_vin.h56
-rw-r--r--drivers/gpu/nvgpu/gp106/acr_gp106.c1169
-rw-r--r--drivers/gpu/nvgpu/gp106/acr_gp106.h128
-rw-r--r--drivers/gpu/nvgpu/gp106/bios_gp106.c121
-rw-r--r--drivers/gpu/nvgpu/gp106/bios_gp106.h31
-rw-r--r--drivers/gpu/nvgpu/gp106/clk_arb_gp106.c105
-rw-r--r--drivers/gpu/nvgpu/gp106/clk_arb_gp106.h21
-rw-r--r--drivers/gpu/nvgpu/gp106/clk_gp106.c273
-rw-r--r--drivers/gpu/nvgpu/gp106/clk_gp106.h56
-rw-r--r--drivers/gpu/nvgpu/gp106/fb_gp106.c44
-rw-r--r--drivers/gpu/nvgpu/gp106/fb_gp106.h19
-rw-r--r--drivers/gpu/nvgpu/gp106/fifo_gp106.c30
-rw-r--r--drivers/gpu/nvgpu/gp106/fifo_gp106.h18
-rw-r--r--drivers/gpu/nvgpu/gp106/gp106_gating_reglist.c649
-rw-r--r--drivers/gpu/nvgpu/gp106/gp106_gating_reglist.h87
-rw-r--r--drivers/gpu/nvgpu/gp106/gr_ctx_gp106.c50
-rw-r--r--drivers/gpu/nvgpu/gp106/gr_ctx_gp106.h27
-rw-r--r--drivers/gpu/nvgpu/gp106/gr_gp106.c239
-rw-r--r--drivers/gpu/nvgpu/gp106/gr_gp106.h26
-rw-r--r--drivers/gpu/nvgpu/gp106/hal_gp106.c259
-rw-r--r--drivers/gpu/nvgpu/gp106/hal_gp106.h21
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_bus_gp106.h193
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_ccsr_gp106.h125
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_ce_gp106.h81
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_ctxsw_prog_gp106.h289
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_fb_gp106.h609
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_fbpa_gp106.h61
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_fifo_gp106.h685
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_flush_gp106.h181
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_fuse_gp106.h217
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_gc6_gp106.h56
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_gmmu_gp106.h1261
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_gr_gp106.h4017
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_ltc_gp106.h553
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_mc_gp106.h245
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_pbdma_gp106.h513
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_perf_gp106.h205
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_pri_ringmaster_gp106.h145
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_pri_ringstation_sys_gp106.h69
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_proj_gp106.h165
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_psec_gp106.h609
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_pwr_gp106.h841
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_ram_gp106.h481
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_therm_gp106.h177
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_timer_gp106.h109
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_top_gp106.h221
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_trim_gp106.h189
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_xp_gp106.h137
-rw-r--r--drivers/gpu/nvgpu/gp106/hw_xve_gp106.h149
-rw-r--r--drivers/gpu/nvgpu/gp106/ltc_gp106.c29
-rw-r--r--drivers/gpu/nvgpu/gp106/ltc_gp106.h19
-rw-r--r--drivers/gpu/nvgpu/gp106/mm_gp106.c41
-rw-r--r--drivers/gpu/nvgpu/gp106/mm_gp106.h23
-rw-r--r--drivers/gpu/nvgpu/gp106/pmu_gp106.c296
-rw-r--r--drivers/gpu/nvgpu/gp106/pmu_gp106.h22
-rw-r--r--drivers/gpu/nvgpu/gp106/regops_gp106.c1815
-rw-r--r--drivers/gpu/nvgpu/gp106/regops_gp106.h24
-rw-r--r--drivers/gpu/nvgpu/gp106/sec2_gp106.c388
-rw-r--r--drivers/gpu/nvgpu/gp106/sec2_gp106.h29
-rw-r--r--drivers/gpu/nvgpu/gp106/therm_gp106.c128
-rw-r--r--drivers/gpu/nvgpu/gp106/therm_gp106.h22
-rw-r--r--drivers/gpu/nvgpu/gp106/xve_gp106.c623
-rw-r--r--drivers/gpu/nvgpu/gp106/xve_gp106.h99
-rw-r--r--drivers/gpu/nvgpu/gp10b/cde_gp10b.c148
-rw-r--r--drivers/gpu/nvgpu/gp10b/cde_gp10b.h23
-rw-r--r--drivers/gpu/nvgpu/gp10b/ce_gp10b.c82
-rw-r--r--drivers/gpu/nvgpu/gp10b/ce_gp10b.h26
-rw-r--r--drivers/gpu/nvgpu/gp10b/fb_gp10b.c108
-rw-r--r--drivers/gpu/nvgpu/gp10b/fb_gp10b.h21
-rw-r--r--drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.c53
-rw-r--r--drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.h23
-rw-r--r--drivers/gpu/nvgpu/gp10b/fifo_gp10b.c238
-rw-r--r--drivers/gpu/nvgpu/gp10b/fifo_gp10b.h21
-rw-r--r--drivers/gpu/nvgpu/gp10b/gp10b.c110
-rw-r--r--drivers/gpu/nvgpu/gp10b/gp10b.h26
-rw-r--r--drivers/gpu/nvgpu/gp10b/gp10b_gating_reglist.c640
-rw-r--r--drivers/gpu/nvgpu/gp10b/gp10b_gating_reglist.h93
-rw-r--r--drivers/gpu/nvgpu/gp10b/gp10b_sysfs.c64
-rw-r--r--drivers/gpu/nvgpu/gp10b/gp10b_sysfs.h29
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_ctx_gp10b.c73
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_ctx_gp10b.h28
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_gp10b.c2257
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_gp10b.h103
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_ops_gp10b.h28
-rw-r--r--drivers/gpu/nvgpu/gp10b/hal_gp10b.c269
-rw-r--r--drivers/gpu/nvgpu/gp10b/hal_gp10b.h21
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_bus_gp10b.h217
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_ccsr_gp10b.h117
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_ce_gp10b.h81
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_chiplet_pwr_gp10b.h85
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_ctxsw_prog_gp10b.h473
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_fb_gp10b.h481
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_fifo_gp10b.h689
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_flush_gp10b.h181
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_fuse_gp10b.h145
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_gmmu_gp10b.h1277
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_gr_gp10b.h4241
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_ltc_gp10b.h581
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_mc_gp10b.h245
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_pbdma_gp10b.h593
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_perf_gp10b.h205
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_pram_gp10b.h57
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_pri_ringmaster_gp10b.h145
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_pri_ringstation_sys_gp10b.h69
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_proj_gp10b.h165
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_pwr_gp10b.h825
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_ram_gp10b.h493
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_therm_gp10b.h409
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_timer_gp10b.h109
-rw-r--r--drivers/gpu/nvgpu/gp10b/hw_top_gp10b.h225
-rw-r--r--drivers/gpu/nvgpu/gp10b/ltc_gp10b.c225
-rw-r--r--drivers/gpu/nvgpu/gp10b/ltc_gp10b.h19
-rw-r--r--drivers/gpu/nvgpu/gp10b/mc_gp10b.c202
-rw-r--r--drivers/gpu/nvgpu/gp10b/mc_gp10b.h31
-rw-r--r--drivers/gpu/nvgpu/gp10b/mm_gp10b.c417
-rw-r--r--drivers/gpu/nvgpu/gp10b/mm_gp10b.h22
-rw-r--r--drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c751
-rw-r--r--drivers/gpu/nvgpu/gp10b/pmu_gp10b.c493
-rw-r--r--drivers/gpu/nvgpu/gp10b/pmu_gp10b.h26
-rw-r--r--drivers/gpu/nvgpu/gp10b/regops_gp10b.c511
-rw-r--r--drivers/gpu/nvgpu/gp10b/regops_gp10b.h24
-rw-r--r--drivers/gpu/nvgpu/gp10b/rpfb_gp10b.c150
-rw-r--r--drivers/gpu/nvgpu/gp10b/rpfb_gp10b.h30
-rw-r--r--drivers/gpu/nvgpu/gp10b/therm_gp10b.c130
-rw-r--r--drivers/gpu/nvgpu/gp10b/therm_gp10b.h19
-rw-r--r--drivers/gpu/nvgpu/gr_t18x.h20
-rw-r--r--drivers/gpu/nvgpu/include/bios.h992
-rw-r--r--drivers/gpu/nvgpu/lpwr/lpwr.c423
-rw-r--r--drivers/gpu/nvgpu/lpwr/lpwr.h92
-rw-r--r--drivers/gpu/nvgpu/lpwr/rppg.c158
-rw-r--r--drivers/gpu/nvgpu/lpwr/rppg.h17
-rw-r--r--drivers/gpu/nvgpu/nvgpu_gpuid_t18x.h45
-rw-r--r--drivers/gpu/nvgpu/perf/perf.c118
-rw-r--r--drivers/gpu/nvgpu/perf/perf.h66
-rw-r--r--drivers/gpu/nvgpu/perf/vfe_equ.c590
-rw-r--r--drivers/gpu/nvgpu/perf/vfe_equ.h76
-rw-r--r--drivers/gpu/nvgpu/perf/vfe_var.c1048
-rw-r--r--drivers/gpu/nvgpu/perf/vfe_var.h97
-rw-r--r--drivers/gpu/nvgpu/pmgr/pmgr.c176
-rw-r--r--drivers/gpu/nvgpu/pmgr/pmgr.h34
-rw-r--r--drivers/gpu/nvgpu/pmgr/pmgrpmu.c524
-rw-r--r--drivers/gpu/nvgpu/pmgr/pmgrpmu.h29
-rw-r--r--drivers/gpu/nvgpu/pmgr/pwrdev.c310
-rw-r--r--drivers/gpu/nvgpu/pmgr/pwrdev.h51
-rw-r--r--drivers/gpu/nvgpu/pmgr/pwrmonitor.c365
-rw-r--r--drivers/gpu/nvgpu/pmgr/pwrmonitor.h60
-rw-r--r--drivers/gpu/nvgpu/pmgr/pwrpolicy.c765
-rw-r--r--drivers/gpu/nvgpu/pmgr/pwrpolicy.h127
-rw-r--r--drivers/gpu/nvgpu/pmuif/gpmuifseq.h73
-rw-r--r--drivers/gpu/nvgpu/pstate/pstate.c407
-rw-r--r--drivers/gpu/nvgpu/pstate/pstate.h63
-rw-r--r--drivers/gpu/nvgpu/therm/thrm.c45
-rw-r--r--drivers/gpu/nvgpu/therm/thrm.h29
-rw-r--r--drivers/gpu/nvgpu/therm/thrmchannel.c246
-rw-r--r--drivers/gpu/nvgpu/therm/thrmchannel.h42
-rw-r--r--drivers/gpu/nvgpu/therm/thrmdev.c193
-rw-r--r--drivers/gpu/nvgpu/therm/thrmdev.h31
-rw-r--r--drivers/gpu/nvgpu/therm/thrmpmu.c142
-rw-r--r--drivers/gpu/nvgpu/therm/thrmpmu.h22
-rw-r--r--drivers/gpu/nvgpu/vgpu/gp10b/vgpu_fifo_gp10b.c48
-rw-r--r--drivers/gpu/nvgpu/vgpu/gp10b/vgpu_fifo_gp10b.h21
-rw-r--r--drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.c321
-rw-r--r--drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.h21
-rw-r--r--drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c36
-rw-r--r--drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c188
-rw-r--r--drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.h21
-rw-r--r--drivers/gpu/nvgpu/volt/volt.h30
-rw-r--r--drivers/gpu/nvgpu/volt/volt_dev.c588
-rw-r--r--drivers/gpu/nvgpu/volt/volt_dev.h69
-rw-r--r--drivers/gpu/nvgpu/volt/volt_pmu.c276
-rw-r--r--drivers/gpu/nvgpu/volt/volt_pmu.h23
-rw-r--r--drivers/gpu/nvgpu/volt/volt_policy.c360
-rw-r--r--drivers/gpu/nvgpu/volt/volt_policy.h64
-rw-r--r--drivers/gpu/nvgpu/volt/volt_rail.c438
-rw-r--r--drivers/gpu/nvgpu/volt/volt_rail.h79
-rw-r--r--include/linux/tegra_vgpu_t18x.h42
-rw-r--r--include/uapi/linux/nvgpu-t18x.h74
196 files changed, 58712 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/Makefile.nvgpu-t18x b/drivers/gpu/nvgpu/Makefile.nvgpu-t18x
new file mode 100644
index 00000000..30119345
--- /dev/null
+++ b/drivers/gpu/nvgpu/Makefile.nvgpu-t18x
@@ -0,0 +1,75 @@
1nvgpu-t18x := $(call tegra-path,nvgpu-t18x,drivers/gpu/nvgpu)
2
3nvgpu-y += \
4 $(nvgpu-t18x)/gp10b/gr_gp10b.o \
5 $(nvgpu-t18x)/gp10b/gr_ctx_gp10b.o \
6 $(nvgpu-t18x)/gp10b/ce_gp10b.o \
7 $(nvgpu-t18x)/gp10b/mc_gp10b.o \
8 $(nvgpu-t18x)/gp10b/fifo_gp10b.o \
9 $(nvgpu-t18x)/gp10b/ltc_gp10b.o \
10 $(nvgpu-t18x)/gp10b/mm_gp10b.o \
11 $(nvgpu-t18x)/gp10b/fb_gp10b.o \
12 $(nvgpu-t18x)/gp10b/pmu_gp10b.o \
13 $(nvgpu-t18x)/gp10b/hal_gp10b.o \
14 $(nvgpu-t18x)/gp10b/rpfb_gp10b.o \
15 $(nvgpu-t18x)/gp10b/gp10b_gating_reglist.o \
16 $(nvgpu-t18x)/gp10b/regops_gp10b.o \
17 $(nvgpu-t18x)/gp10b/cde_gp10b.o \
18 $(nvgpu-t18x)/gp10b/therm_gp10b.o \
19 $(nvgpu-t18x)/gp10b/fecs_trace_gp10b.o \
20 $(nvgpu-t18x)/gp10b/gp10b_sysfs.o \
21 $(nvgpu-t18x)/gp10b/gp10b.o \
22 $(nvgpu-t18x)/gp106/hal_gp106.o \
23 $(nvgpu-t18x)/gp106/mm_gp106.o \
24 $(nvgpu-t18x)/gp106/pmu_gp106.o \
25 $(nvgpu-t18x)/gp106/gr_gp106.o \
26 $(nvgpu-t18x)/gp106/gr_ctx_gp106.o \
27 $(nvgpu-t18x)/gp106/acr_gp106.o \
28 $(nvgpu-t18x)/gp106/sec2_gp106.o \
29 $(nvgpu-t18x)/gp106/fifo_gp106.o \
30 $(nvgpu-t18x)/gp106/ltc_gp106.o \
31 $(nvgpu-t18x)/gp106/fb_gp106.o \
32 $(nvgpu-t18x)/gp106/bios_gp106.o \
33 $(nvgpu-t18x)/gp106/regops_gp106.o \
34 $(nvgpu-t18x)/clk/clk_mclk.o \
35 $(nvgpu-t18x)/pstate/pstate.o \
36 $(nvgpu-t18x)/clk/clk_vin.o \
37 $(nvgpu-t18x)/clk/clk_fll.o \
38 $(nvgpu-t18x)/clk/clk_domain.o \
39 $(nvgpu-t18x)/clk/clk_prog.o \
40 $(nvgpu-t18x)/clk/clk_vf_point.o \
41 $(nvgpu-t18x)/clk/clk_arb.o \
42 $(nvgpu-t18x)/clk/clk_freq_controller.o \
43 $(nvgpu-t18x)/perf/vfe_var.o \
44 $(nvgpu-t18x)/perf/vfe_equ.o \
45 $(nvgpu-t18x)/perf/perf.o \
46 $(nvgpu-t18x)/clk/clk.o \
47 $(nvgpu-t18x)/gp106/clk_gp106.o \
48 $(nvgpu-t18x)/gp106/clk_arb_gp106.o \
49 $(nvgpu-t18x)/gp106/gp106_gating_reglist.o \
50 $(nvgpu-t18x)/gp106/xve_gp106.o \
51 $(nvgpu-t18x)/gp106/therm_gp106.o \
52 $(nvgpu-t18x)/gp106/xve_gp106.o \
53 $(nvgpu-t18x)/pmgr/pwrdev.o \
54 $(nvgpu-t18x)/pmgr/pmgr.o \
55 $(nvgpu-t18x)/pmgr/pmgrpmu.o \
56 $(nvgpu-t18x)/pmgr/pwrmonitor.o \
57 $(nvgpu-t18x)/pmgr/pwrpolicy.o \
58 $(nvgpu-t18x)/volt/volt_rail.o \
59 $(nvgpu-t18x)/volt/volt_dev.o \
60 $(nvgpu-t18x)/volt/volt_policy.o \
61 $(nvgpu-t18x)/volt/volt_pmu.o \
62 $(nvgpu-t18x)/therm/thrm.o \
63 $(nvgpu-t18x)/therm/thrmdev.o \
64 $(nvgpu-t18x)/therm/thrmchannel.o \
65 $(nvgpu-t18x)/therm/thrmpmu.o \
66 $(nvgpu-t18x)/lpwr/rppg.o \
67 $(nvgpu-t18x)/lpwr/lpwr.o
68
69nvgpu-$(CONFIG_TEGRA_GK20A) += $(nvgpu-t18x)/gp10b/platform_gp10b_tegra.o
70
71nvgpu-$(CONFIG_TEGRA_GR_VIRTUALIZATION) += \
72 $(nvgpu-t18x)/vgpu/gp10b/vgpu_hal_gp10b.o \
73 $(nvgpu-t18x)/vgpu/gp10b/vgpu_gr_gp10b.o \
74 $(nvgpu-t18x)/vgpu/gp10b/vgpu_mm_gp10b.o \
75 $(nvgpu-t18x)/vgpu/gp10b/vgpu_fifo_gp10b.o
diff --git a/drivers/gpu/nvgpu/acr_t18x.h b/drivers/gpu/nvgpu/acr_t18x.h
new file mode 100644
index 00000000..1e48d5ca
--- /dev/null
+++ b/drivers/gpu/nvgpu/acr_t18x.h
@@ -0,0 +1,20 @@
1/*
2 * NVIDIA T18x ACR
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _NVGPU_ACR_T18X_H_
16#define _NVGPU_ACR_T18X_H_
17
18#include "gp106/acr_gp106.h"
19
20#endif
diff --git a/drivers/gpu/nvgpu/clk/clk.c b/drivers/gpu/nvgpu/clk/clk.c
new file mode 100644
index 00000000..ecd53c02
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk.c
@@ -0,0 +1,529 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "clk.h"
16#include "pmuif/gpmuifclk.h"
17#include "pmuif/gpmuifvolt.h"
18#include "ctrl/ctrlclk.h"
19#include "ctrl/ctrlvolt.h"
20#include "volt/volt.h"
21#include "gk20a/pmu_gk20a.h"
22
23#define BOOT_GPC2CLK_MHZ 2581
24#define BOOT_MCLK_MHZ 3003
25
26struct clkrpc_pmucmdhandler_params {
27 struct nv_pmu_clk_rpc *prpccall;
28 u32 success;
29};
30
31static void clkrpc_pmucmdhandler(struct gk20a *g, struct pmu_msg *msg,
32 void *param, u32 handle, u32 status)
33{
34 struct clkrpc_pmucmdhandler_params *phandlerparams =
35 (struct clkrpc_pmucmdhandler_params *)param;
36
37 gk20a_dbg_info("");
38
39 if (msg->msg.clk.msg_type != NV_PMU_CLK_MSG_ID_RPC) {
40 gk20a_err(dev_from_gk20a(g),
41 "unsupported msg for VFE LOAD RPC %x",
42 msg->msg.clk.msg_type);
43 return;
44 }
45
46 if (phandlerparams->prpccall->b_supported)
47 phandlerparams->success = 1;
48}
49
50int clk_pmu_freq_controller_load(struct gk20a *g, bool bload)
51{
52 struct pmu_cmd cmd;
53 struct pmu_msg msg;
54 struct pmu_payload payload = { {0} };
55 u32 status;
56 u32 seqdesc;
57 struct nv_pmu_clk_rpc rpccall = {0};
58 struct clkrpc_pmucmdhandler_params handler = {0};
59 struct nv_pmu_clk_load *clkload;
60 struct clk_freq_controllers *pclk_freq_controllers;
61 struct ctrl_boardobjgrp_mask_e32 *load_mask;
62
63 pclk_freq_controllers = &g->clk_pmu.clk_freq_controllers;
64 rpccall.function = NV_PMU_CLK_RPC_ID_LOAD;
65 clkload = &rpccall.params.clk_load;
66 clkload->feature = NV_NV_PMU_CLK_LOAD_FEATURE_FREQ_CONTROLLER;
67 clkload->action_mask = bload ?
68 NV_NV_PMU_CLK_LOAD_ACTION_MASK_FREQ_CONTROLLER_CALLBACK_YES :
69 NV_NV_PMU_CLK_LOAD_ACTION_MASK_FREQ_CONTROLLER_CALLBACK_NO;
70
71 load_mask = &rpccall.params.clk_load.payload.freq_controllers.load_mask;
72
73 status = boardobjgrpmask_export(
74 &pclk_freq_controllers->freq_ctrl_load_mask.super,
75 pclk_freq_controllers->freq_ctrl_load_mask.super.bitcount,
76 &load_mask->super);
77
78 cmd.hdr.unit_id = PMU_UNIT_CLK;
79 cmd.hdr.size = (u32)sizeof(struct nv_pmu_clk_cmd) +
80 (u32)sizeof(struct pmu_hdr);
81
82 cmd.cmd.clk.cmd_type = NV_PMU_CLK_CMD_ID_RPC;
83 msg.hdr.size = sizeof(struct pmu_msg);
84
85 payload.in.buf = (u8 *)&rpccall;
86 payload.in.size = (u32)sizeof(struct nv_pmu_clk_rpc);
87 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
88 payload.in.offset = NV_PMU_CLK_CMD_RPC_ALLOC_OFFSET;
89
90 payload.out.buf = (u8 *)&rpccall;
91 payload.out.size = (u32)sizeof(struct nv_pmu_clk_rpc);
92 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
93 payload.out.offset = NV_PMU_CLK_MSG_RPC_ALLOC_OFFSET;
94
95 handler.prpccall = &rpccall;
96 handler.success = 0;
97 status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload,
98 PMU_COMMAND_QUEUE_LPQ,
99 clkrpc_pmucmdhandler, (void *)&handler,
100 &seqdesc, ~0);
101
102 if (status) {
103 gk20a_err(dev_from_gk20a(g),
104 "unable to post clk RPC cmd %x",
105 cmd.cmd.clk.cmd_type);
106 goto done;
107 }
108
109 pmu_wait_message_cond(&g->pmu,
110 gk20a_get_gr_idle_timeout(g),
111 &handler.success, 1);
112
113 if (handler.success == 0) {
114 gk20a_err(dev_from_gk20a(g), "rpc call to load freq cntlr cal failed");
115 status = -EINVAL;
116 }
117
118done:
119 return status;
120}
121
122u32 clk_pmu_vin_load(struct gk20a *g)
123{
124 struct pmu_cmd cmd;
125 struct pmu_msg msg;
126 struct pmu_payload payload = { {0} };
127 u32 status;
128 u32 seqdesc;
129 struct nv_pmu_clk_rpc rpccall = {0};
130 struct clkrpc_pmucmdhandler_params handler = {0};
131 struct nv_pmu_clk_load *clkload;
132
133 rpccall.function = NV_PMU_CLK_RPC_ID_LOAD;
134 clkload = &rpccall.params.clk_load;
135 clkload->feature = NV_NV_PMU_CLK_LOAD_FEATURE_VIN;
136 clkload->action_mask = NV_NV_PMU_CLK_LOAD_ACTION_MASK_VIN_HW_CAL_PROGRAM_YES << 4;
137
138 cmd.hdr.unit_id = PMU_UNIT_CLK;
139 cmd.hdr.size = (u32)sizeof(struct nv_pmu_clk_cmd) +
140 (u32)sizeof(struct pmu_hdr);
141
142 cmd.cmd.clk.cmd_type = NV_PMU_CLK_CMD_ID_RPC;
143 msg.hdr.size = sizeof(struct pmu_msg);
144
145 payload.in.buf = (u8 *)&rpccall;
146 payload.in.size = (u32)sizeof(struct nv_pmu_clk_rpc);
147 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
148 payload.in.offset = NV_PMU_CLK_CMD_RPC_ALLOC_OFFSET;
149
150 payload.out.buf = (u8 *)&rpccall;
151 payload.out.size = (u32)sizeof(struct nv_pmu_clk_rpc);
152 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
153 payload.out.offset = NV_PMU_CLK_MSG_RPC_ALLOC_OFFSET;
154
155 handler.prpccall = &rpccall;
156 handler.success = 0;
157 status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload,
158 PMU_COMMAND_QUEUE_LPQ,
159 clkrpc_pmucmdhandler, (void *)&handler,
160 &seqdesc, ~0);
161
162 if (status) {
163 gk20a_err(dev_from_gk20a(g),
164 "unable to post clk RPC cmd %x",
165 cmd.cmd.clk.cmd_type);
166 goto done;
167 }
168
169 pmu_wait_message_cond(&g->pmu,
170 gk20a_get_gr_idle_timeout(g),
171 &handler.success, 1);
172
173 if (handler.success == 0) {
174 gk20a_err(dev_from_gk20a(g), "rpc call to load vin cal failed");
175 status = -EINVAL;
176 }
177
178done:
179 return status;
180}
181
182static u32 clk_pmu_vf_inject(struct gk20a *g, struct set_fll_clk *setfllclk)
183{
184 struct pmu_cmd cmd;
185 struct pmu_msg msg;
186 struct pmu_payload payload = { {0} };
187 u32 status;
188 u32 seqdesc;
189 struct nv_pmu_clk_rpc rpccall = {0};
190 struct clkrpc_pmucmdhandler_params handler = {0};
191 struct nv_pmu_clk_vf_change_inject *vfchange;
192
193 if ((setfllclk->gpc2clkmhz == 0) || (setfllclk->xbar2clkmhz == 0) ||
194 (setfllclk->sys2clkmhz == 0) || (setfllclk->voltuv == 0))
195 return -EINVAL;
196
197 if ((setfllclk->target_regime_id_gpc > CTRL_CLK_FLL_REGIME_ID_FR) ||
198 (setfllclk->target_regime_id_sys > CTRL_CLK_FLL_REGIME_ID_FR) ||
199 (setfllclk->target_regime_id_xbar > CTRL_CLK_FLL_REGIME_ID_FR))
200 return -EINVAL;
201
202 rpccall.function = NV_PMU_CLK_RPC_ID_CLK_VF_CHANGE_INJECT;
203 vfchange = &rpccall.params.clk_vf_change_inject;
204 vfchange->flags = 0;
205 vfchange->clk_list.num_domains = 3;
206 vfchange->clk_list.clk_domains[0].clk_domain = CTRL_CLK_DOMAIN_GPC2CLK;
207 vfchange->clk_list.clk_domains[0].clk_freq_khz =
208 setfllclk->gpc2clkmhz * 1000;
209 vfchange->clk_list.clk_domains[0].clk_flags = 0;
210 vfchange->clk_list.clk_domains[0].current_regime_id =
211 setfllclk->current_regime_id_gpc;
212 vfchange->clk_list.clk_domains[0].target_regime_id =
213 setfllclk->target_regime_id_gpc;
214 vfchange->clk_list.clk_domains[1].clk_domain = CTRL_CLK_DOMAIN_XBAR2CLK;
215 vfchange->clk_list.clk_domains[1].clk_freq_khz =
216 setfllclk->xbar2clkmhz * 1000;
217 vfchange->clk_list.clk_domains[1].clk_flags = 0;
218 vfchange->clk_list.clk_domains[1].current_regime_id =
219 setfllclk->current_regime_id_xbar;
220 vfchange->clk_list.clk_domains[1].target_regime_id =
221 setfllclk->target_regime_id_xbar;
222 vfchange->clk_list.clk_domains[2].clk_domain = CTRL_CLK_DOMAIN_SYS2CLK;
223 vfchange->clk_list.clk_domains[2].clk_freq_khz =
224 setfllclk->sys2clkmhz * 1000;
225 vfchange->clk_list.clk_domains[2].clk_flags = 0;
226 vfchange->clk_list.clk_domains[2].current_regime_id =
227 setfllclk->current_regime_id_sys;
228 vfchange->clk_list.clk_domains[2].target_regime_id =
229 setfllclk->target_regime_id_sys;
230 vfchange->volt_list.num_rails = 1;
231 vfchange->volt_list.rails[0].volt_domain = CTRL_VOLT_DOMAIN_LOGIC;
232 vfchange->volt_list.rails[0].voltage_uv = setfllclk->voltuv;
233 vfchange->volt_list.rails[0].voltage_min_noise_unaware_uv =
234 setfllclk->voltuv;
235
236 cmd.hdr.unit_id = PMU_UNIT_CLK;
237 cmd.hdr.size = (u32)sizeof(struct nv_pmu_clk_cmd) +
238 (u32)sizeof(struct pmu_hdr);
239
240 cmd.cmd.clk.cmd_type = NV_PMU_CLK_CMD_ID_RPC;
241 msg.hdr.size = sizeof(struct pmu_msg);
242
243 payload.in.buf = (u8 *)&rpccall;
244 payload.in.size = (u32)sizeof(struct nv_pmu_clk_rpc);
245 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
246 payload.in.offset = NV_PMU_CLK_CMD_RPC_ALLOC_OFFSET;
247
248 payload.out.buf = (u8 *)&rpccall;
249 payload.out.size = (u32)sizeof(struct nv_pmu_clk_rpc);
250 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
251 payload.out.offset = NV_PMU_CLK_MSG_RPC_ALLOC_OFFSET;
252
253 handler.prpccall = &rpccall;
254 handler.success = 0;
255
256 status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload,
257 PMU_COMMAND_QUEUE_LPQ,
258 clkrpc_pmucmdhandler, (void *)&handler,
259 &seqdesc, ~0);
260
261 if (status) {
262 gk20a_err(dev_from_gk20a(g),
263 "unable to post clk RPC cmd %x",
264 cmd.cmd.clk.cmd_type);
265 goto done;
266 }
267
268 pmu_wait_message_cond(&g->pmu,
269 gk20a_get_gr_idle_timeout(g),
270 &handler.success, 1);
271
272 if (handler.success == 0) {
273 gk20a_err(dev_from_gk20a(g), "rpc call to inject clock failed");
274 status = -EINVAL;
275 }
276done:
277 return status;
278}
279
280static u32 find_regime_id(struct gk20a *g, u32 domain, u16 clkmhz)
281{
282 struct fll_device *pflldev;
283 u8 j;
284 struct clk_pmupstate *pclk = &g->clk_pmu;
285
286 BOARDOBJGRP_FOR_EACH(&(pclk->avfs_fllobjs.super.super),
287 struct fll_device *, pflldev, j) {
288 if (pflldev->clk_domain == domain) {
289 if (pflldev->regime_desc.fixed_freq_regime_limit_mhz >=
290 clkmhz)
291 return CTRL_CLK_FLL_REGIME_ID_FFR;
292 else
293 return CTRL_CLK_FLL_REGIME_ID_FR;
294 }
295 }
296 return CTRL_CLK_FLL_REGIME_ID_INVALID;
297}
298
299static int set_regime_id(struct gk20a *g, u32 domain, u32 regimeid)
300{
301 struct fll_device *pflldev;
302 u8 j;
303 struct clk_pmupstate *pclk = &g->clk_pmu;
304
305 BOARDOBJGRP_FOR_EACH(&(pclk->avfs_fllobjs.super.super),
306 struct fll_device *, pflldev, j) {
307 if (pflldev->clk_domain == domain) {
308 pflldev->regime_desc.regime_id = regimeid;
309 return 0;
310 }
311 }
312 return -EINVAL;
313}
314
315static int get_regime_id(struct gk20a *g, u32 domain, u32 *regimeid)
316{
317 struct fll_device *pflldev;
318 u8 j;
319 struct clk_pmupstate *pclk = &g->clk_pmu;
320
321 BOARDOBJGRP_FOR_EACH(&(pclk->avfs_fllobjs.super.super),
322 struct fll_device *, pflldev, j) {
323 if (pflldev->clk_domain == domain) {
324 *regimeid = pflldev->regime_desc.regime_id;
325 return 0;
326 }
327 }
328 return -EINVAL;
329}
330
331int clk_set_fll_clks(struct gk20a *g, struct set_fll_clk *setfllclk)
332{
333 int status = -EINVAL;
334
335 /*set regime ids */
336 status = get_regime_id(g, CTRL_CLK_DOMAIN_GPC2CLK,
337 &setfllclk->current_regime_id_gpc);
338 if (status)
339 goto done;
340
341 setfllclk->target_regime_id_gpc = find_regime_id(g,
342 CTRL_CLK_DOMAIN_GPC2CLK, setfllclk->gpc2clkmhz);
343
344 status = get_regime_id(g, CTRL_CLK_DOMAIN_SYS2CLK,
345 &setfllclk->current_regime_id_sys);
346 if (status)
347 goto done;
348
349 setfllclk->target_regime_id_sys = find_regime_id(g,
350 CTRL_CLK_DOMAIN_SYS2CLK, setfllclk->sys2clkmhz);
351
352 status = get_regime_id(g, CTRL_CLK_DOMAIN_XBAR2CLK,
353 &setfllclk->current_regime_id_xbar);
354 if (status)
355 goto done;
356
357 setfllclk->target_regime_id_xbar = find_regime_id(g,
358 CTRL_CLK_DOMAIN_XBAR2CLK, setfllclk->xbar2clkmhz);
359
360 status = clk_pmu_vf_inject(g, setfllclk);
361
362 if (status)
363 gk20a_err(dev_from_gk20a(g),
364 "vf inject to change clk failed");
365
366 /* save regime ids */
367 status = set_regime_id(g, CTRL_CLK_DOMAIN_XBAR2CLK,
368 setfllclk->target_regime_id_xbar);
369 if (status)
370 goto done;
371
372 status = set_regime_id(g, CTRL_CLK_DOMAIN_GPC2CLK,
373 setfllclk->target_regime_id_gpc);
374 if (status)
375 goto done;
376
377 status = set_regime_id(g, CTRL_CLK_DOMAIN_SYS2CLK,
378 setfllclk->target_regime_id_sys);
379 if (status)
380 goto done;
381done:
382 return status;
383}
384
385int clk_get_fll_clks(struct gk20a *g, struct set_fll_clk *setfllclk)
386{
387 int status = -EINVAL;
388 struct clk_domain *pdomain;
389 u8 i;
390 struct clk_pmupstate *pclk = &g->clk_pmu;
391 u16 clkmhz = 0;
392 struct clk_domain_3x_master *p3xmaster;
393 struct clk_domain_3x_slave *p3xslave;
394 unsigned long slaveidxmask;
395
396 if (setfllclk->gpc2clkmhz == 0)
397 return -EINVAL;
398
399 BOARDOBJGRP_FOR_EACH(&(pclk->clk_domainobjs.super.super),
400 struct clk_domain *, pdomain, i) {
401
402 if (pdomain->api_domain == CTRL_CLK_DOMAIN_GPC2CLK) {
403
404 if (!pdomain->super.implements(g, &pdomain->super,
405 CTRL_CLK_CLK_DOMAIN_TYPE_3X_MASTER)) {
406 status = -EINVAL;
407 goto done;
408 }
409 p3xmaster = (struct clk_domain_3x_master *)pdomain;
410 slaveidxmask = p3xmaster->slave_idxs_mask;
411 for_each_set_bit(i, &slaveidxmask, 32) {
412 p3xslave = (struct clk_domain_3x_slave *)
413 CLK_CLK_DOMAIN_GET(pclk, i);
414 if ((p3xslave->super.super.super.api_domain !=
415 CTRL_CLK_DOMAIN_XBAR2CLK) &&
416 (p3xslave->super.super.super.api_domain !=
417 CTRL_CLK_DOMAIN_SYS2CLK))
418 continue;
419 clkmhz = 0;
420 status = p3xslave->clkdomainclkgetslaveclk(g,
421 pclk,
422 (struct clk_domain *)p3xslave,
423 &clkmhz,
424 setfllclk->gpc2clkmhz);
425 if (status) {
426 status = -EINVAL;
427 goto done;
428 }
429 if (p3xslave->super.super.super.api_domain ==
430 CTRL_CLK_DOMAIN_XBAR2CLK)
431 setfllclk->xbar2clkmhz = clkmhz;
432 if (p3xslave->super.super.super.api_domain ==
433 CTRL_CLK_DOMAIN_SYS2CLK)
434 setfllclk->sys2clkmhz = clkmhz;
435 }
436 }
437 }
438done:
439 return status;
440}
441
442u32 clk_domain_print_vf_table(struct gk20a *g, u32 clkapidomain)
443{
444 u32 status = -EINVAL;
445 struct clk_domain *pdomain;
446 u8 i;
447 struct clk_pmupstate *pclk = &g->clk_pmu;
448 u16 clkmhz = 0;
449 u32 volt = 0;
450
451 BOARDOBJGRP_FOR_EACH(&(pclk->clk_domainobjs.super.super),
452 struct clk_domain *, pdomain, i) {
453 if (pdomain->api_domain == clkapidomain) {
454 status = pdomain->clkdomainclkvfsearch(g, pclk,
455 pdomain, &clkmhz, &volt,
456 CLK_PROG_VFE_ENTRY_LOGIC);
457 status = pdomain->clkdomainclkvfsearch(g, pclk,
458 pdomain, &clkmhz, &volt,
459 CLK_PROG_VFE_ENTRY_SRAM);
460 }
461 }
462 return status;
463}
464
465u32 clk_domain_get_f_or_v(
466 struct gk20a *g,
467 u32 clkapidomain,
468 u16 *pclkmhz,
469 u32 *pvoltuv,
470 u8 railidx
471)
472{
473 u32 status = -EINVAL;
474 struct clk_domain *pdomain;
475 u8 i;
476 struct clk_pmupstate *pclk = &g->clk_pmu;
477 u8 rail;
478
479 if ((pclkmhz == NULL) || (pvoltuv == NULL))
480 return -EINVAL;
481
482 if (railidx == CTRL_VOLT_DOMAIN_LOGIC)
483 rail = CLK_PROG_VFE_ENTRY_LOGIC;
484 else if (railidx == CTRL_VOLT_DOMAIN_SRAM)
485 rail = CLK_PROG_VFE_ENTRY_SRAM;
486 else
487 return -EINVAL;
488
489 BOARDOBJGRP_FOR_EACH(&(pclk->clk_domainobjs.super.super),
490 struct clk_domain *, pdomain, i) {
491 if (pdomain->api_domain == clkapidomain) {
492 status = pdomain->clkdomainclkvfsearch(g, pclk,
493 pdomain, pclkmhz, pvoltuv, rail);
494 return status;
495 }
496 }
497 return status;
498}
499
500u32 clk_domain_get_f_points(
501 struct gk20a *g,
502 u32 clkapidomain,
503 u32 *pfpointscount,
504 u16 *pfreqpointsinmhz
505)
506{
507 u32 status = -EINVAL;
508 struct clk_domain *pdomain;
509 u8 i;
510 struct clk_pmupstate *pclk = &g->clk_pmu;
511
512 if (pfpointscount == NULL)
513 return -EINVAL;
514
515 if ((pfreqpointsinmhz == NULL) && (*pfpointscount != 0))
516 return -EINVAL;
517
518 BOARDOBJGRP_FOR_EACH(&(pclk->clk_domainobjs.super.super),
519 struct clk_domain *, pdomain, i) {
520 if (pdomain->api_domain == clkapidomain) {
521 status = pdomain->clkdomainclkgetfpoints(g, pclk,
522 pdomain, pfpointscount,
523 pfreqpointsinmhz,
524 CLK_PROG_VFE_ENTRY_LOGIC);
525 return status;
526 }
527 }
528 return status;
529}
diff --git a/drivers/gpu/nvgpu/clk/clk.h b/drivers/gpu/nvgpu/clk/clk.h
new file mode 100644
index 00000000..b173a09e
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk.h
@@ -0,0 +1,120 @@
1/*
2 * general clock structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _CLK_H_
16#define _CLK_H_
17
18#include "clk_vin.h"
19#include "clk_fll.h"
20#include "clk_domain.h"
21#include "clk_prog.h"
22#include "clk_vf_point.h"
23#include "clk_mclk.h"
24#include "clk_freq_controller.h"
25#include "gk20a/gk20a.h"
26
27#define NV_PERF_DOMAIN_4X_CLOCK_DOMAIN_SKIP 0x10
28#define NV_PERF_DOMAIN_4X_CLOCK_DOMAIN_MASK 0x1F
29#define NV_PERF_DOMAIN_4X_CLOCK_DOMAIN_SHIFT 0
30
31/* clock related defines for GPUs supporting clock control from pmu*/
32struct clk_pmupstate {
33 struct avfsvinobjs avfs_vinobjs;
34 struct avfsfllobjs avfs_fllobjs;
35 struct clk_domains clk_domainobjs;
36 struct clk_progs clk_progobjs;
37 struct clk_vf_points clk_vf_pointobjs;
38 struct clk_mclk_state clk_mclk;
39 struct clk_freq_controllers clk_freq_controllers;
40};
41
42struct clockentry {
43 u8 vbios_clk_domain;
44 u8 clk_which;
45 u8 perf_index;
46 u32 api_clk_domain;
47};
48
49struct set_fll_clk {
50 u32 voltuv;
51 u16 gpc2clkmhz;
52 u32 current_regime_id_gpc;
53 u32 target_regime_id_gpc;
54 u16 sys2clkmhz;
55 u32 current_regime_id_sys;
56 u32 target_regime_id_sys;
57 u16 xbar2clkmhz;
58 u32 current_regime_id_xbar;
59 u32 target_regime_id_xbar;
60};
61
62#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_MAX_NUMCLKS 9
63
64struct vbios_clock_domain {
65 u8 clock_type;
66 u8 num_domains;
67 struct clockentry clock_entry[NV_PERF_HEADER_4X_CLOCKS_DOMAINS_MAX_NUMCLKS];
68};
69
70struct vbios_clocks_table_1x_hal_clock_entry {
71 enum nv_pmu_clk_clkwhich domain;
72 bool b_noise_aware_capable;
73};
74
75#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_4_GPC2CLK 0
76#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_4_XBAR2CLK 1
77#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_4_DRAMCLK 2
78#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_4_SYS2CLK 3
79#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_4_HUB2CLK 4
80#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_4_MSDCLK 5
81#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_4_PWRCLK 6
82#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_4_DISPCLK 7
83#define NV_PERF_HEADER_4X_CLOCKS_DOMAINS_4_NUMCLKS 8
84
85#define PERF_CLK_MCLK 0
86#define PERF_CLK_DISPCLK 1
87#define PERF_CLK_GPC2CLK 2
88#define PERF_CLK_HOSTCLK 3
89#define PERF_CLK_LTC2CLK 4
90#define PERF_CLK_SYS2CLK 5
91#define PERF_CLK_HUB2CLK 6
92#define PERF_CLK_LEGCLK 7
93#define PERF_CLK_MSDCLK 8
94#define PERF_CLK_XCLK 9
95#define PERF_CLK_PWRCLK 10
96#define PERF_CLK_XBAR2CLK 11
97#define PERF_CLK_PCIEGENCLK 12
98#define PERF_CLK_NUM 13
99
100#define BOOT_GPC2CLK_MHZ 2581
101
102u32 clk_pmu_vin_load(struct gk20a *g);
103u32 clk_domain_print_vf_table(struct gk20a *g, u32 clkapidomain);
104u32 clk_domain_get_f_or_v(
105 struct gk20a *g,
106 u32 clkapidomain,
107 u16 *pclkmhz,
108 u32 *pvoltuv,
109 u8 railidx
110);
111u32 clk_domain_get_f_points(
112 struct gk20a *g,
113 u32 clkapidomain,
114 u32 *fpointscount,
115 u16 *freqpointsinmhz
116);
117int clk_get_fll_clks(struct gk20a *g, struct set_fll_clk *fllclk);
118int clk_set_fll_clks(struct gk20a *g, struct set_fll_clk *fllclk);
119int clk_pmu_freq_controller_load(struct gk20a *g, bool bload);
120#endif
diff --git a/drivers/gpu/nvgpu/clk/clk_arb.c b/drivers/gpu/nvgpu/clk/clk_arb.c
new file mode 100644
index 00000000..c440dc3b
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_arb.c
@@ -0,0 +1,1548 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15
16#include <linux/cdev.h>
17#include <linux/file.h>
18#include <linux/anon_inodes.h>
19#include <linux/nvgpu.h>
20#include <linux/bitops.h>
21#include <linux/spinlock.h>
22#include <linux/rculist.h>
23#include <linux/llist.h>
24#include "clk/clk_arb.h"
25
26
27#define MAX_F_POINTS 127
28
29#ifdef CONFIG_DEBUG_FS
30static int nvgpu_clk_arb_debugfs_init(struct gk20a *g);
31#endif
32
33static int nvgpu_clk_arb_release_event_dev(struct inode *inode,
34 struct file *filp);
35static int nvgpu_clk_arb_release_completion_dev(struct inode *inode,
36 struct file *filp);
37static unsigned int nvgpu_clk_arb_poll_dev(struct file *filp, poll_table *wait);
38
39static void nvgpu_clk_arb_run_arbiter_cb(struct work_struct *work);
40static void nvgpu_clk_arb_run_vf_table_cb(struct work_struct *work);
41static int nvgpu_clk_arb_update_vf_table(struct nvgpu_clk_arb *arb);
42static void nvgpu_clk_arb_free_fd(struct kref *refcount);
43static void nvgpu_clk_arb_free_session(struct kref *refcount);
44static int nvgpu_clk_arb_change_vf_point(struct gk20a *g, u16 gpc2clk_target,
45 u16 sys2clk_target, u16 xbar2clk_target, u16 mclk_target, u32 voltuv,
46 u32 voltuv_sram);
47static u8 nvgpu_clk_arb_find_vf_point(struct nvgpu_clk_arb *arb,
48 u16 *gpc2clk, u16 *sys2clk, u16 *xbar2clk, u16 *mclk,
49 u32 *voltuv, u32 *voltuv_sram, u32 *nuvmin, u32 *nuvmin_sram);
50
51#define VF_POINT_INVALID_PSTATE ~0U
52#define VF_POINT_SET_PSTATE_SUPPORTED(a, b) ((a)->pstates |= (1UL << (b)))
53#define VF_POINT_GET_PSTATE(a) (((a)->pstates) ?\
54 __fls((a)->pstates) :\
55 VF_POINT_INVALID_PSTATE)
56#define VF_POINT_COMMON_PSTATE(a, b) (((a)->pstates & (b)->pstates) ?\
57 __fls((a)->pstates & (b)->pstates) :\
58 VF_POINT_INVALID_PSTATE)
59
60struct nvgpu_clk_vf_point {
61 u16 pstates;
62 union {
63 struct {
64 u16 gpc_mhz;
65 u16 sys_mhz;
66 u16 xbar_mhz;
67 };
68 u16 mem_mhz;
69 };
70 u32 uvolt;
71 u32 uvolt_sram;
72};
73
74struct nvgpu_clk_vf_table {
75 u32 mclk_num_points;
76 struct nvgpu_clk_vf_point *mclk_points;
77 u32 gpc2clk_num_points;
78 struct nvgpu_clk_vf_point *gpc2clk_points;
79};
80#ifdef CONFIG_DEBUG_FS
81struct nvgpu_clk_arb_debug {
82 s64 switch_max;
83 s64 switch_min;
84 u64 switch_num;
85 s64 switch_avg;
86 s64 switch_std;
87};
88#endif
89
90struct nvgpu_clk_arb_target {
91 u16 mclk;
92 u16 gpc2clk;
93 u32 pstate;
94};
95
96struct nvgpu_clk_arb {
97 spinlock_t sessions_lock;
98 spinlock_t users_lock;
99
100 struct mutex pstate_lock;
101 struct list_head users;
102 struct list_head sessions;
103 struct llist_head requests;
104
105 struct gk20a *g;
106 int status;
107
108 struct nvgpu_clk_arb_target actual_pool[2];
109 struct nvgpu_clk_arb_target *actual;
110
111 u16 gpc2clk_default_mhz;
112 u16 mclk_default_mhz;
113 u32 voltuv_actual;
114
115 struct work_struct update_fn_work;
116 struct workqueue_struct *update_work_queue;
117 struct work_struct vf_table_fn_work;
118 struct workqueue_struct *vf_table_work_queue;
119
120 wait_queue_head_t request_wq;
121
122 struct nvgpu_clk_vf_table *current_vf_table;
123 struct nvgpu_clk_vf_table vf_table_pool[2];
124 u32 vf_table_index;
125
126 u16 *mclk_f_points;
127 atomic_t req_nr;
128
129 u32 mclk_f_numpoints;
130 u16 *gpc2clk_f_points;
131 u32 gpc2clk_f_numpoints;
132
133#ifdef CONFIG_DEBUG_FS
134 struct nvgpu_clk_arb_debug debug_pool[2];
135 struct nvgpu_clk_arb_debug *debug;
136 bool debugfs_set;
137#endif
138};
139
140struct nvgpu_clk_dev {
141 struct nvgpu_clk_session *session;
142 union {
143 struct list_head link;
144 struct llist_node node;
145 };
146 wait_queue_head_t readout_wq;
147 atomic_t poll_mask;
148 u16 gpc2clk_target_mhz;
149 u16 mclk_target_mhz;
150 struct kref refcount;
151};
152
153struct nvgpu_clk_session {
154 bool zombie;
155 struct gk20a *g;
156 struct kref refcount;
157 struct list_head link;
158 struct llist_head targets;
159
160 struct nvgpu_clk_arb_target target_pool[2];
161 struct nvgpu_clk_arb_target *target;
162};
163
164static const struct file_operations completion_dev_ops = {
165 .owner = THIS_MODULE,
166 .release = nvgpu_clk_arb_release_completion_dev,
167 .poll = nvgpu_clk_arb_poll_dev,
168};
169
170static const struct file_operations event_dev_ops = {
171 .owner = THIS_MODULE,
172 .release = nvgpu_clk_arb_release_event_dev,
173 .poll = nvgpu_clk_arb_poll_dev,
174};
175
176int nvgpu_clk_arb_init_arbiter(struct gk20a *g)
177{
178 struct nvgpu_clk_arb *arb;
179 u16 default_mhz;
180 int err;
181 int index;
182 struct nvgpu_clk_vf_table *table;
183
184 gk20a_dbg_fn("");
185
186 if (!g->ops.clk_arb.get_arbiter_clk_domains)
187 return 0;
188
189 arb = kzalloc(sizeof(struct nvgpu_clk_arb), GFP_KERNEL);
190 if (!arb) {
191 err = -ENOMEM;
192 goto init_fail;
193 }
194
195 arb->mclk_f_points = kcalloc(MAX_F_POINTS, sizeof(u16), GFP_KERNEL);
196 if (!arb->mclk_f_points) {
197 err = -ENOMEM;
198 goto init_fail;
199 }
200
201 arb->gpc2clk_f_points = kcalloc(MAX_F_POINTS, sizeof(u16), GFP_KERNEL);
202 if (!arb->gpc2clk_f_points) {
203 err = -ENOMEM;
204 goto init_fail;
205 }
206
207 for (index = 0; index < 2; index++) {
208 table = &arb->vf_table_pool[index];
209 table->gpc2clk_num_points = MAX_F_POINTS;
210 table->mclk_num_points = MAX_F_POINTS;
211
212 table->gpc2clk_points = kcalloc(MAX_F_POINTS,
213 sizeof(struct nvgpu_clk_vf_point), GFP_KERNEL);
214 if (!table->gpc2clk_points) {
215 err = -ENOMEM;
216 goto init_fail;
217 }
218
219
220 table->mclk_points = kcalloc(MAX_F_POINTS,
221 sizeof(struct nvgpu_clk_vf_point), GFP_KERNEL);
222 if (!table->mclk_points) {
223 err = -ENOMEM;
224 goto init_fail;
225 }
226 }
227
228 g->clk_arb = arb;
229 arb->g = g;
230
231 mutex_init(&arb->pstate_lock);
232 spin_lock_init(&arb->sessions_lock);
233 spin_lock_init(&arb->users_lock);
234
235 err = g->ops.clk_arb.get_arbiter_clk_default(g,
236 NVGPU_GPU_CLK_DOMAIN_MCLK, &default_mhz);
237 if (err) {
238 err = -EINVAL;
239 goto init_fail;
240 }
241
242 arb->mclk_default_mhz = default_mhz;
243
244 err = g->ops.clk_arb.get_arbiter_clk_default(g,
245 NVGPU_GPU_CLK_DOMAIN_GPC2CLK, &default_mhz);
246 if (err) {
247 err = -EINVAL;
248 goto init_fail;
249 }
250
251 arb->gpc2clk_default_mhz = default_mhz;
252
253 arb->actual = &arb->actual_pool[0];
254
255 atomic_set(&arb->req_nr, 0);
256
257 INIT_LIST_HEAD_RCU(&arb->users);
258 INIT_LIST_HEAD_RCU(&arb->sessions);
259 init_llist_head(&arb->requests);
260
261 init_waitqueue_head(&arb->request_wq);
262 arb->vf_table_work_queue = alloc_workqueue("%s", WQ_HIGHPRI, 1,
263 "vf_table_update");
264 arb->update_work_queue = alloc_workqueue("%s", WQ_HIGHPRI, 1,
265 "arbiter_update");
266
267
268 INIT_WORK(&arb->vf_table_fn_work, nvgpu_clk_arb_run_vf_table_cb);
269
270 INIT_WORK(&arb->update_fn_work, nvgpu_clk_arb_run_arbiter_cb);
271
272#ifdef CONFIG_DEBUG_FS
273 arb->debug = &arb->debug_pool[0];
274
275 if (!arb->debugfs_set) {
276 if (nvgpu_clk_arb_debugfs_init(g))
277 arb->debugfs_set = true;
278 }
279#endif
280 err = clk_vf_point_cache(g);
281 if (err < 0)
282 goto init_fail;
283
284 err = nvgpu_clk_arb_update_vf_table(arb);
285 if (err < 0)
286 goto init_fail;
287 do {
288 /* Check that first run is completed */
289 smp_mb();
290 wait_event_interruptible(arb->request_wq,
291 atomic_read(&arb->req_nr));
292 } while (!atomic_read(&arb->req_nr));
293
294
295 return arb->status;
296
297init_fail:
298
299 kfree(arb->gpc2clk_f_points);
300 kfree(arb->mclk_f_points);
301
302 for (index = 0; index < 2; index++) {
303 kfree(arb->vf_table_pool[index].gpc2clk_points);
304 kfree(arb->vf_table_pool[index].mclk_points);
305 }
306
307 kfree(arb);
308
309 return err;
310}
311
312void nvgpu_clk_arb_cleanup_arbiter(struct gk20a *g)
313{
314 kfree(g->clk_arb);
315}
316
317static int nvgpu_clk_arb_install_fd(struct gk20a *g,
318 struct nvgpu_clk_session *session,
319 const struct file_operations *fops,
320 struct nvgpu_clk_dev **_dev)
321{
322 struct file *file;
323 char *name;
324 int fd;
325 int err;
326 struct nvgpu_clk_dev *dev;
327
328 gk20a_dbg_fn("");
329
330 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
331 if (!dev)
332 return -ENOMEM;
333
334 fd = get_unused_fd_flags(O_RDWR);
335 if (fd < 0)
336 return fd;
337
338 name = kasprintf(GFP_KERNEL, "%s-clk-fd%d", dev_name(g->dev), fd);
339 file = anon_inode_getfile(name, fops, dev, O_RDWR);
340 kfree(name);
341 if (IS_ERR(file)) {
342 err = PTR_ERR(file);
343 goto fail;
344 }
345
346 fd_install(fd, file);
347
348 init_waitqueue_head(&dev->readout_wq);
349 atomic_set(&dev->poll_mask, 0);
350
351 dev->session = session;
352 kref_init(&dev->refcount);
353
354 kref_get(&session->refcount);
355
356 *_dev = dev;
357
358 return fd;
359
360fail:
361 kfree(dev);
362 put_unused_fd(fd);
363
364 return err;
365}
366
367int nvgpu_clk_arb_init_session(struct gk20a *g,
368 struct nvgpu_clk_session **_session)
369{
370 struct nvgpu_clk_arb *arb = g->clk_arb;
371 struct nvgpu_clk_session *session = *(_session);
372
373 gk20a_dbg_fn("");
374
375 if (!g->ops.clk_arb.get_arbiter_clk_domains)
376 return 0;
377
378 session = kzalloc(sizeof(struct nvgpu_clk_session), GFP_KERNEL);
379 if (!session)
380 return -ENOMEM;
381 session->g = g;
382
383 kref_init(&session->refcount);
384
385 session->zombie = false;
386 session->target_pool[0].pstate = CTRL_PERF_PSTATE_P8;
387 /* make sure that the initialization of the pool is visible
388 * before the update */
389 smp_wmb();
390 session->target = &session->target_pool[0];
391
392 init_llist_head(&session->targets);
393
394 spin_lock(&arb->sessions_lock);
395 list_add_tail_rcu(&session->link, &arb->sessions);
396 spin_unlock(&arb->sessions_lock);
397
398 *_session = session;
399
400 return 0;
401}
402
403static void nvgpu_clk_arb_free_fd(struct kref *refcount)
404{
405 struct nvgpu_clk_dev *dev = container_of(refcount,
406 struct nvgpu_clk_dev, refcount);
407
408 kfree(dev);
409}
410
411static void nvgpu_clk_arb_free_session(struct kref *refcount)
412{
413 struct nvgpu_clk_session *session = container_of(refcount,
414 struct nvgpu_clk_session, refcount);
415 struct nvgpu_clk_arb *arb = session->g->clk_arb;
416 struct nvgpu_clk_dev *dev, *tmp;
417 struct llist_node *head;
418
419 gk20a_dbg_fn("");
420
421 spin_lock(&arb->sessions_lock);
422 list_del_rcu(&session->link);
423 spin_unlock(&arb->sessions_lock);
424
425 head = llist_del_all(&session->targets);
426 llist_for_each_entry_safe(dev, tmp, head, node) {
427 kref_put(&dev->refcount, nvgpu_clk_arb_free_fd);
428 }
429 synchronize_rcu();
430 kfree(session);
431}
432
433void nvgpu_clk_arb_release_session(struct gk20a *g,
434 struct nvgpu_clk_session *session)
435{
436 struct nvgpu_clk_arb *arb = g->clk_arb;
437
438 gk20a_dbg_fn("");
439
440 session->zombie = true;
441 kref_put(&session->refcount, nvgpu_clk_arb_free_session);
442
443 queue_work(arb->update_work_queue, &arb->update_fn_work);
444}
445
446int nvgpu_clk_arb_install_event_fd(struct gk20a *g,
447 struct nvgpu_clk_session *session, int *event_fd)
448{
449 struct nvgpu_clk_arb *arb = g->clk_arb;
450 struct nvgpu_clk_dev *dev;
451 int fd;
452
453 gk20a_dbg_fn("");
454
455 fd = nvgpu_clk_arb_install_fd(g, session, &event_dev_ops, &dev);
456 if (fd < 0)
457 return fd;
458
459 spin_lock(&arb->users_lock);
460 list_add_tail_rcu(&dev->link, &arb->users);
461 spin_unlock(&arb->users_lock);
462
463 *event_fd = fd;
464
465 return 0;
466}
467
468int nvgpu_clk_arb_install_request_fd(struct gk20a *g,
469 struct nvgpu_clk_session *session, int *request_fd)
470{
471 struct nvgpu_clk_dev *dev;
472 int fd;
473
474 gk20a_dbg_fn("");
475
476 fd = nvgpu_clk_arb_install_fd(g, session, &completion_dev_ops, &dev);
477 if (fd < 0)
478 return fd;
479
480 *request_fd = fd;
481
482 return 0;
483}
484
485static int nvgpu_clk_arb_update_vf_table(struct nvgpu_clk_arb *arb)
486{
487 struct gk20a *g = arb->g;
488 struct nvgpu_clk_vf_table *table;
489
490 u32 i, j;
491 int status = -EINVAL;
492 u32 gpc2clk_voltuv = 0, mclk_voltuv = 0;
493 u32 gpc2clk_voltuv_sram = 0, mclk_voltuv_sram = 0;
494 u16 gpc2clk_min, gpc2clk_max, clk_cur;
495 u16 mclk_min, mclk_max;
496 u32 num_points;
497
498 struct clk_set_info *p5_info, *p0_info;
499
500
501 table = ACCESS_ONCE(arb->current_vf_table);
502 /* make flag visible when all data has resolved in the tables */
503 smp_rmb();
504
505 table = (table == &arb->vf_table_pool[0]) ? &arb->vf_table_pool[1] :
506 &arb->vf_table_pool[0];
507
508 /* Get allowed memory ranges */
509 if (nvgpu_clk_arb_get_arbiter_clk_range(g, NVGPU_GPU_CLK_DOMAIN_GPC2CLK,
510 &gpc2clk_min,
511 &gpc2clk_max) < 0) {
512 gk20a_err(dev_from_gk20a(g),
513 "failed to fetch GPC2CLK range");
514 goto exit_vf_table;
515 }
516 if (nvgpu_clk_arb_get_arbiter_clk_range(g, NVGPU_GPU_CLK_DOMAIN_MCLK,
517 &mclk_min, &mclk_max) < 0) {
518 gk20a_err(dev_from_gk20a(g),
519 "failed to fetch MCLK range");
520 goto exit_vf_table;
521 }
522
523 if (clk_domain_get_f_points(arb->g, NVGPU_GPU_CLK_DOMAIN_GPC2CLK,
524 &table->gpc2clk_num_points, arb->gpc2clk_f_points)) {
525 gk20a_err(dev_from_gk20a(g),
526 "failed to fetch GPC2CLK frequency points");
527 goto exit_vf_table;
528 }
529
530 table->gpc2clk_num_points = MAX_F_POINTS;
531 table->mclk_num_points = MAX_F_POINTS;
532
533 if (clk_domain_get_f_points(arb->g, NVGPU_GPU_CLK_DOMAIN_MCLK,
534 &table->mclk_num_points, arb->mclk_f_points)) {
535 gk20a_err(dev_from_gk20a(g),
536 "failed to fetch MCLK frequency points");
537 goto exit_vf_table;
538 }
539 if (!table->mclk_num_points || !table->gpc2clk_num_points) {
540 gk20a_err(dev_from_gk20a(g),
541 "empty queries to f points mclk %d gpc2clk %d",
542 table->mclk_num_points, table->gpc2clk_num_points);
543 status = -EINVAL;
544 goto exit_vf_table;
545 }
546
547 memset(table->mclk_points, 0,
548 table->mclk_num_points*sizeof(struct nvgpu_clk_vf_point));
549 memset(table->gpc2clk_points, 0,
550 table->gpc2clk_num_points*sizeof(struct nvgpu_clk_vf_point));
551
552 p5_info = pstate_get_clk_set_info(g,
553 CTRL_PERF_PSTATE_P5, clkwhich_mclk);
554 if (!p5_info) {
555 gk20a_err(dev_from_gk20a(g),
556 "failed to get MCLK P5 info");
557 goto exit_vf_table;
558 }
559 p0_info = pstate_get_clk_set_info(g,
560 CTRL_PERF_PSTATE_P0, clkwhich_mclk);
561 if (!p0_info) {
562 gk20a_err(dev_from_gk20a(g),
563 "failed to get MCLK P0 info");
564 goto exit_vf_table;
565 }
566
567 for (i = 0, j = 0, num_points = 0, clk_cur = 0;
568 i < table->mclk_num_points; i++) {
569
570 if ((arb->mclk_f_points[i] >= mclk_min) &&
571 (arb->mclk_f_points[i] <= mclk_max) &&
572 (arb->mclk_f_points[i] != clk_cur)) {
573
574 table->mclk_points[j].mem_mhz = arb->mclk_f_points[i];
575 mclk_voltuv = mclk_voltuv_sram = 0;
576
577 status = clk_domain_get_f_or_v(g, CTRL_CLK_DOMAIN_MCLK,
578 &table->mclk_points[j].mem_mhz, &mclk_voltuv,
579 CTRL_VOLT_DOMAIN_LOGIC);
580 if (status < 0) {
581 gk20a_err(dev_from_gk20a(g),
582 "failed to get MCLK LOGIC voltage");
583 goto exit_vf_table;
584 }
585 status = clk_domain_get_f_or_v(g, CTRL_CLK_DOMAIN_MCLK,
586 &table->mclk_points[j].mem_mhz,
587 &mclk_voltuv_sram,
588 CTRL_VOLT_DOMAIN_SRAM);
589 if (status < 0) {
590 gk20a_err(dev_from_gk20a(g),
591 "failed to get MCLK SRAM voltage");
592 goto exit_vf_table;
593 }
594
595 table->mclk_points[j].uvolt = mclk_voltuv;
596 table->mclk_points[j].uvolt_sram = mclk_voltuv_sram;
597 clk_cur = table->mclk_points[j].mem_mhz;
598
599 if ((clk_cur >= p5_info->min_mhz) &&
600 (clk_cur <= p5_info->max_mhz))
601 VF_POINT_SET_PSTATE_SUPPORTED(
602 &table->mclk_points[j],
603 CTRL_PERF_PSTATE_P5);
604 if ((clk_cur >= p0_info->min_mhz) &&
605 (clk_cur <= p0_info->max_mhz))
606 VF_POINT_SET_PSTATE_SUPPORTED(
607 &table->mclk_points[j],
608 CTRL_PERF_PSTATE_P0);
609
610 j++;
611 num_points++;
612
613 }
614 }
615 table->mclk_num_points = num_points;
616
617 p5_info = pstate_get_clk_set_info(g,
618 CTRL_PERF_PSTATE_P5, clkwhich_gpc2clk);
619 if (!p5_info) {
620 status = -EINVAL;
621 gk20a_err(dev_from_gk20a(g),
622 "failed to get GPC2CLK P5 info");
623 goto exit_vf_table;
624 }
625
626 p0_info = pstate_get_clk_set_info(g,
627 CTRL_PERF_PSTATE_P0, clkwhich_gpc2clk);
628 if (!p0_info) {
629 status = -EINVAL;
630 gk20a_err(dev_from_gk20a(g),
631 "failed to get GPC2CLK P0 info");
632 goto exit_vf_table;
633 }
634
635 /* GPC2CLK needs to be checked in two passes. The first determines the
636 * relationships between GPC2CLK, SYS2CLK and XBAR2CLK, while the
637 * second verifies that the clocks minimum is satisfied and sets
638 * the voltages
639 */
640 for (i = 0, j = 0, num_points = 0, clk_cur = 0;
641 i < table->gpc2clk_num_points; i++) {
642 struct set_fll_clk setfllclk;
643
644 if ((arb->gpc2clk_f_points[i] >= gpc2clk_min) &&
645 (arb->gpc2clk_f_points[i] <= gpc2clk_max) &&
646 (arb->gpc2clk_f_points[i] != clk_cur)) {
647
648 table->gpc2clk_points[j].gpc_mhz =
649 arb->gpc2clk_f_points[i];
650 setfllclk.gpc2clkmhz = arb->gpc2clk_f_points[i];
651 status = clk_get_fll_clks(g, &setfllclk);
652 if (status < 0) {
653 gk20a_err(dev_from_gk20a(g),
654 "failed to get GPC2CLK slave clocks");
655 goto exit_vf_table;
656 }
657
658 table->gpc2clk_points[j].sys_mhz =
659 setfllclk.sys2clkmhz;
660 table->gpc2clk_points[j].xbar_mhz =
661 setfllclk.xbar2clkmhz;
662
663 clk_cur = table->gpc2clk_points[j].gpc_mhz;
664
665 if ((clk_cur >= p5_info->min_mhz) &&
666 (clk_cur <= p5_info->max_mhz))
667 VF_POINT_SET_PSTATE_SUPPORTED(
668 &table->gpc2clk_points[j],
669 CTRL_PERF_PSTATE_P5);
670 if ((clk_cur >= p0_info->min_mhz) &&
671 (clk_cur <= p0_info->max_mhz))
672 VF_POINT_SET_PSTATE_SUPPORTED(
673 &table->gpc2clk_points[j],
674 CTRL_PERF_PSTATE_P0);
675
676 j++;
677 num_points++;
678 }
679 }
680 table->gpc2clk_num_points = num_points;
681
682 /* Second pass */
683 for (i = 0, j = 0; i < table->gpc2clk_num_points; i++) {
684
685 u16 alt_gpc2clk = table->gpc2clk_points[i].gpc_mhz;
686 gpc2clk_voltuv = gpc2clk_voltuv_sram = 0;
687
688 /* Check sysclk */
689 p5_info = pstate_get_clk_set_info(g,
690 VF_POINT_GET_PSTATE(&table->gpc2clk_points[i]),
691 clkwhich_sys2clk);
692 if (!p5_info) {
693 status = -EINVAL;
694 gk20a_err(dev_from_gk20a(g),
695 "failed to get SYS2CLK P5 info");
696 goto exit_vf_table;
697 }
698
699 /* sys2clk below clk min, need to find correct clock */
700 if (table->gpc2clk_points[i].sys_mhz < p5_info->min_mhz) {
701 for (j = i + 1; j < table->gpc2clk_num_points; j++) {
702
703 if (table->gpc2clk_points[j].sys_mhz >=
704 p5_info->min_mhz) {
705
706
707 table->gpc2clk_points[i].sys_mhz =
708 p5_info->min_mhz;
709
710 alt_gpc2clk = alt_gpc2clk <
711 table->gpc2clk_points[j].
712 gpc_mhz ?
713 table->gpc2clk_points[j].
714 gpc_mhz:
715 alt_gpc2clk;
716 break;
717 }
718 }
719 /* no VF exists that satisfies condition */
720 if (j == table->gpc2clk_num_points) {
721 gk20a_err(dev_from_gk20a(g),
722 "NO SYS2CLK VF point possible");
723 status = -EINVAL;
724 goto exit_vf_table;
725 }
726 }
727
728 /* Check xbarclk */
729 p5_info = pstate_get_clk_set_info(g,
730 VF_POINT_GET_PSTATE(&table->gpc2clk_points[i]),
731 clkwhich_xbar2clk);
732 if (!p5_info) {
733 status = -EINVAL;
734 gk20a_err(dev_from_gk20a(g),
735 "failed to get SYS2CLK P5 info");
736 goto exit_vf_table;
737 }
738
739 /* xbar2clk below clk min, need to find correct clock */
740 if (table->gpc2clk_points[i].xbar_mhz < p5_info->min_mhz) {
741 for (j = i; j < table->gpc2clk_num_points; j++) {
742 if (table->gpc2clk_points[j].xbar_mhz >=
743 p5_info->min_mhz) {
744
745 table->gpc2clk_points[i].xbar_mhz =
746 p5_info->min_mhz;
747
748 alt_gpc2clk = alt_gpc2clk <
749 table->gpc2clk_points[j].
750 gpc_mhz ?
751 table->gpc2clk_points[j].
752 gpc_mhz:
753 alt_gpc2clk;
754 break;
755 }
756 }
757 /* no VF exists that satisfies condition */
758 if (j == table->gpc2clk_num_points) {
759 status = -EINVAL;
760 gk20a_err(dev_from_gk20a(g),
761 "NO XBAR2CLK VF point possible");
762
763 goto exit_vf_table;
764 }
765 }
766
767 /* Calculate voltages */
768 status = clk_domain_get_f_or_v(g, CTRL_CLK_DOMAIN_GPC2CLK,
769 &alt_gpc2clk, &gpc2clk_voltuv,
770 CTRL_VOLT_DOMAIN_LOGIC);
771 if (status < 0) {
772 gk20a_err(dev_from_gk20a(g),
773 "failed to get GPC2CLK LOGIC voltage");
774 goto exit_vf_table;
775 }
776
777 status = clk_domain_get_f_or_v(g, CTRL_CLK_DOMAIN_GPC2CLK,
778 &alt_gpc2clk,
779 &gpc2clk_voltuv_sram,
780 CTRL_VOLT_DOMAIN_SRAM);
781 if (status < 0) {
782 gk20a_err(dev_from_gk20a(g),
783 "failed to get GPC2CLK SRAM voltage");
784 goto exit_vf_table;
785 }
786
787 table->gpc2clk_points[i].uvolt = gpc2clk_voltuv;
788 table->gpc2clk_points[i].uvolt_sram = gpc2clk_voltuv_sram;
789 }
790
791 /* make table visible when all data has resolved in the tables */
792 smp_wmb();
793 xchg(&arb->current_vf_table, table);
794
795 queue_work(arb->update_work_queue, &arb->update_fn_work);
796exit_vf_table:
797
798 return status;
799}
800
801void nvgpu_clk_arb_schedule_vf_table_update(struct gk20a *g)
802{
803 struct nvgpu_clk_arb *arb = g->clk_arb;
804
805 queue_work(arb->vf_table_work_queue, &arb->vf_table_fn_work);
806}
807
808static void nvgpu_clk_arb_run_vf_table_cb(struct work_struct *work)
809{
810 struct nvgpu_clk_arb *arb =
811 container_of(work, struct nvgpu_clk_arb, vf_table_fn_work);
812 struct gk20a *g = arb->g;
813 u32 err;
814
815 /* get latest vf curve from pmu */
816 err = clk_vf_point_cache(g);
817 if (err) {
818 gk20a_err(dev_from_gk20a(g),
819 "failed to cache VF table");
820 return;
821 }
822 nvgpu_clk_arb_update_vf_table(arb);
823}
824
825static void nvgpu_clk_arb_run_arbiter_cb(struct work_struct *work)
826{
827 struct nvgpu_clk_arb *arb =
828 container_of(work, struct nvgpu_clk_arb, update_fn_work);
829 struct nvgpu_clk_session *session;
830 struct nvgpu_clk_dev *dev;
831 struct nvgpu_clk_dev *tmp;
832 struct nvgpu_clk_arb_target *target, *actual;
833 struct gk20a *g = arb->g;
834 struct llist_node *head;
835
836 u32 pstate = VF_POINT_INVALID_PSTATE;
837 u32 voltuv, voltuv_sram;
838 bool mclk_set, gpc2clk_set;
839 u32 nuvmin, nuvmin_sram;
840
841 int status = 0;
842
843 /* Temporary variables for checking target frequency */
844 u16 gpc2clk_target, sys2clk_target, xbar2clk_target, mclk_target;
845
846#ifdef CONFIG_DEBUG_FS
847 u64 t0, t1;
848 struct nvgpu_clk_arb_debug *debug;
849
850#endif
851
852 gk20a_dbg_fn("");
853
854#ifdef CONFIG_DEBUG_FS
855 g->ops.read_ptimer(g, &t0);
856#endif
857
858 /* Only one arbiter should be running */
859 gpc2clk_target = 0;
860 mclk_target = 0;
861
862 rcu_read_lock();
863 list_for_each_entry_rcu(session, &arb->sessions, link) {
864 if (!session->zombie) {
865 mclk_set = false;
866 gpc2clk_set = false;
867 target = ACCESS_ONCE(session->target) ==
868 &session->target_pool[0] ?
869 &session->target_pool[1] :
870 &session->target_pool[0];
871 /* Do not reorder pointer */
872 smp_rmb();
873 head = llist_del_all(&session->targets);
874 if (head) {
875
876 /* Copy over state */
877 target->mclk = session->target->mclk;
878 target->gpc2clk = session->target->gpc2clk;
879 /* Query the latest committed request */
880 llist_for_each_entry_safe(dev, tmp, head,
881 node) {
882 if (!mclk_set && dev->mclk_target_mhz) {
883 target->mclk =
884 dev->mclk_target_mhz;
885 mclk_set = true;
886 }
887 if (!gpc2clk_set &&
888 dev->gpc2clk_target_mhz) {
889 target->gpc2clk =
890 dev->gpc2clk_target_mhz;
891 gpc2clk_set = true;
892 }
893 kref_get(&dev->refcount);
894 llist_add(&dev->node, &arb->requests);
895 }
896 /* Ensure target is updated before ptr sawp */
897 smp_wmb();
898 xchg(&session->target, target);
899 }
900
901 mclk_target = mclk_target > session->target->mclk ?
902 mclk_target : session->target->mclk;
903
904 gpc2clk_target =
905 gpc2clk_target > session->target->gpc2clk ?
906 gpc2clk_target : session->target->gpc2clk;
907 }
908 }
909 rcu_read_unlock();
910
911 gpc2clk_target = (gpc2clk_target > 0) ? gpc2clk_target :
912 arb->gpc2clk_default_mhz;
913
914 mclk_target = (mclk_target > 0) ? mclk_target:
915 arb->mclk_default_mhz;
916
917 sys2clk_target = 0;
918 xbar2clk_target = 0;
919 /* Query the table for the closest vf point to program */
920 pstate = nvgpu_clk_arb_find_vf_point(arb, &gpc2clk_target,
921 &sys2clk_target, &xbar2clk_target, &mclk_target, &voltuv,
922 &voltuv_sram, &nuvmin, &nuvmin_sram);
923
924 if (pstate == VF_POINT_INVALID_PSTATE) {
925 arb->status = -EINVAL;
926 /* make status visible */
927 smp_mb();
928 goto exit_arb;
929 }
930
931 if ((arb->actual->gpc2clk == gpc2clk_target) &&
932 (arb->actual->mclk == mclk_target) &&
933 (arb->voltuv_actual == voltuv)) {
934 goto exit_arb;
935 }
936
937 /* Program clocks */
938 /* A change in both mclk of gpc2clk may require a change in voltage */
939
940 mutex_lock(&arb->pstate_lock);
941 status = nvgpu_lpwr_disable_pg(g, false);
942
943 status = clk_pmu_freq_controller_load(g, false);
944 if (status < 0) {
945 arb->status = status;
946 mutex_unlock(&arb->pstate_lock);
947
948 /* make status visible */
949 smp_mb();
950 goto exit_arb;
951 }
952 status = volt_set_noiseaware_vmin(g, nuvmin, nuvmin_sram);
953 if (status < 0) {
954 arb->status = status;
955 mutex_unlock(&arb->pstate_lock);
956
957 /* make status visible */
958 smp_mb();
959 goto exit_arb;
960 }
961
962 status = nvgpu_clk_arb_change_vf_point(g, gpc2clk_target,
963 sys2clk_target, xbar2clk_target, mclk_target, voltuv,
964 voltuv_sram);
965 if (status < 0) {
966 arb->status = status;
967 mutex_unlock(&arb->pstate_lock);
968
969 /* make status visible */
970 smp_mb();
971 goto exit_arb;
972 }
973
974 status = clk_pmu_freq_controller_load(g, true);
975 if (status < 0) {
976 arb->status = status;
977 mutex_unlock(&arb->pstate_lock);
978
979 /* make status visible */
980 smp_mb();
981 goto exit_arb;
982 }
983
984 status = nvgpu_lwpr_mclk_change(g, pstate);
985 if (status < 0) {
986 arb->status = status;
987 mutex_unlock(&arb->pstate_lock);
988
989 /* make status visible */
990 smp_mb();
991 goto exit_arb;
992 }
993
994 actual = ACCESS_ONCE(arb->actual) == &arb->actual_pool[0] ?
995 &arb->actual_pool[1] : &arb->actual_pool[0];
996
997 /* do not reorder this pointer */
998 smp_rmb();
999 actual->gpc2clk = gpc2clk_target;
1000 actual->mclk = mclk_target;
1001 arb->voltuv_actual = voltuv;
1002 actual->pstate = pstate;
1003 arb->status = status;
1004
1005 /* Make changes visible to other threads */
1006 smp_wmb();
1007 xchg(&arb->actual, actual);
1008
1009 status = nvgpu_lpwr_enable_pg(g, false);
1010 if (status < 0) {
1011 arb->status = status;
1012 mutex_unlock(&arb->pstate_lock);
1013
1014 /* make status visible */
1015 smp_mb();
1016 goto exit_arb;
1017 }
1018
1019 /* status must be visible before atomic inc */
1020 smp_wmb();
1021 atomic_inc(&arb->req_nr);
1022
1023 /* Unlock pstate change for PG */
1024 mutex_unlock(&arb->pstate_lock);
1025
1026 wake_up_interruptible(&arb->request_wq);
1027
1028#ifdef CONFIG_DEBUG_FS
1029 g->ops.read_ptimer(g, &t1);
1030
1031 debug = arb->debug == &arb->debug_pool[0] ?
1032 &arb->debug_pool[1] : &arb->debug_pool[0];
1033
1034 memcpy(debug, arb->debug, sizeof(arb->debug_pool[0]));
1035 debug->switch_num++;
1036
1037 if (debug->switch_num == 1) {
1038 debug->switch_max = debug->switch_min =
1039 debug->switch_avg = (t1-t0)/1000;
1040 debug->switch_std = 0;
1041 } else {
1042 s64 prev_avg;
1043 s64 curr = (t1-t0)/1000;
1044
1045 debug->switch_max = curr > debug->switch_max ?
1046 curr : debug->switch_max;
1047 debug->switch_min = debug->switch_min ?
1048 (curr < debug->switch_min ?
1049 curr : debug->switch_min) : curr;
1050 prev_avg = debug->switch_avg;
1051 debug->switch_avg = (curr +
1052 (debug->switch_avg * (debug->switch_num-1))) /
1053 debug->switch_num;
1054 debug->switch_std +=
1055 (curr - debug->switch_avg) * (curr - prev_avg);
1056 }
1057 /* commit changes before exchanging debug pointer */
1058 smp_wmb();
1059 xchg(&arb->debug, debug);
1060#endif
1061
1062exit_arb:
1063 if (status < 0)
1064 gk20a_err(dev_from_gk20a(g),
1065 "Error in arbiter update");
1066
1067 /* notify completion for all requests */
1068 head = llist_del_all(&arb->requests);
1069 llist_for_each_entry_safe(dev, tmp, head, node) {
1070 atomic_set(&dev->poll_mask, POLLIN | POLLRDNORM);
1071 wake_up_interruptible(&dev->readout_wq);
1072 kref_put(&dev->refcount, nvgpu_clk_arb_free_fd);
1073 }
1074
1075 /* notify event for all users */
1076 rcu_read_lock();
1077 list_for_each_entry_rcu(dev, &arb->users, link) {
1078 atomic_set(&dev->poll_mask, POLLIN | POLLRDNORM);
1079 wake_up_interruptible(&dev->readout_wq);
1080 }
1081 rcu_read_unlock();
1082}
1083
1084int nvgpu_clk_arb_commit_request_fd(struct gk20a *g,
1085 struct nvgpu_clk_session *session, int request_fd)
1086{
1087 struct nvgpu_clk_arb *arb = g->clk_arb;
1088 struct nvgpu_clk_dev *dev;
1089 struct fd fd;
1090 int err = 0;
1091
1092 gk20a_dbg_fn("");
1093
1094 fd = fdget(request_fd);
1095
1096 if (!fd.file)
1097 return -EINVAL;
1098
1099 dev = (struct nvgpu_clk_dev *) fd.file->private_data;
1100
1101 if (!dev || dev->session != session) {
1102 err = -EINVAL;
1103 goto fdput_fd;
1104 }
1105 kref_get(&dev->refcount);
1106 llist_add(&dev->node, &session->targets);
1107
1108 queue_work(arb->update_work_queue, &arb->update_fn_work);
1109
1110fdput_fd:
1111 fdput(fd);
1112 return err;
1113}
1114
1115static unsigned int nvgpu_clk_arb_poll_dev(struct file *filp, poll_table *wait)
1116{
1117 struct nvgpu_clk_dev *dev = filp->private_data;
1118
1119 gk20a_dbg_fn("");
1120
1121 poll_wait(filp, &dev->readout_wq, wait);
1122 return atomic_xchg(&dev->poll_mask, 0);
1123}
1124
1125static int nvgpu_clk_arb_release_completion_dev(struct inode *inode,
1126 struct file *filp)
1127{
1128 struct nvgpu_clk_dev *dev = filp->private_data;
1129 struct nvgpu_clk_session *session = dev->session;
1130 struct nvgpu_clk_arb *arb;
1131
1132 arb = session->g->clk_arb;
1133
1134 gk20a_dbg_fn("");
1135
1136 kref_put(&session->refcount, nvgpu_clk_arb_free_session);
1137 kref_put(&dev->refcount, nvgpu_clk_arb_free_fd);
1138
1139 return 0;
1140}
1141
1142static int nvgpu_clk_arb_release_event_dev(struct inode *inode,
1143 struct file *filp)
1144{
1145 struct nvgpu_clk_dev *dev = filp->private_data;
1146 struct nvgpu_clk_session *session = dev->session;
1147 struct nvgpu_clk_arb *arb;
1148
1149 arb = session->g->clk_arb;
1150
1151 gk20a_dbg_fn("");
1152
1153 spin_lock(&arb->users_lock);
1154 list_del_rcu(&dev->link);
1155 spin_unlock(&arb->users_lock);
1156
1157 kref_put(&session->refcount, nvgpu_clk_arb_free_session);
1158 synchronize_rcu();
1159 kfree(dev);
1160
1161 return 0;
1162}
1163
1164int nvgpu_clk_arb_set_session_target_mhz(struct nvgpu_clk_session *session,
1165 int request_fd, u32 api_domain, u16 target_mhz)
1166{
1167 struct nvgpu_clk_dev *dev;
1168 struct fd fd;
1169 int err = 0;
1170
1171 gk20a_dbg_fn("domain=0x%08x target_mhz=%u", api_domain, target_mhz);
1172
1173 fd = fdget(request_fd);
1174
1175 if (!fd.file)
1176 return -EINVAL;
1177
1178 dev = fd.file->private_data;
1179 if (!dev || dev->session != session) {
1180 err = -EINVAL;
1181 goto fdput_fd;
1182 }
1183
1184 switch (api_domain) {
1185 case NVGPU_GPU_CLK_DOMAIN_MCLK:
1186 dev->mclk_target_mhz = target_mhz;
1187 break;
1188
1189 case NVGPU_GPU_CLK_DOMAIN_GPC2CLK:
1190 dev->gpc2clk_target_mhz = target_mhz;
1191 break;
1192
1193 default:
1194 err = -EINVAL;
1195 }
1196
1197fdput_fd:
1198 fdput(fd);
1199 return err;
1200}
1201
1202int nvgpu_clk_arb_get_session_target_mhz(struct nvgpu_clk_session *session,
1203 u32 api_domain, u16 *freq_mhz)
1204{
1205 int err = 0;
1206 struct nvgpu_clk_arb_target *target;
1207
1208 do {
1209 target = ACCESS_ONCE(session->target);
1210 /* no reordering of this pointer */
1211 smp_rmb();
1212
1213 switch (api_domain) {
1214 case NVGPU_GPU_CLK_DOMAIN_MCLK:
1215 *freq_mhz = target->mclk;
1216 break;
1217
1218 case NVGPU_GPU_CLK_DOMAIN_GPC2CLK:
1219 *freq_mhz = target->gpc2clk;
1220 break;
1221
1222 default:
1223 *freq_mhz = 0;
1224 err = -EINVAL;
1225 }
1226 } while (target != ACCESS_ONCE(session->target));
1227 return err;
1228}
1229
1230int nvgpu_clk_arb_get_arbiter_actual_mhz(struct gk20a *g,
1231 u32 api_domain, u16 *freq_mhz)
1232{
1233 struct nvgpu_clk_arb *arb = g->clk_arb;
1234 int err = 0;
1235 struct nvgpu_clk_arb_target *actual;
1236
1237 do {
1238 actual = ACCESS_ONCE(arb->actual);
1239 /* no reordering of this pointer */
1240 smp_rmb();
1241
1242 switch (api_domain) {
1243 case NVGPU_GPU_CLK_DOMAIN_MCLK:
1244 *freq_mhz = actual->mclk;
1245 break;
1246
1247 case NVGPU_GPU_CLK_DOMAIN_GPC2CLK:
1248 *freq_mhz = actual->gpc2clk;
1249 break;
1250
1251 default:
1252 *freq_mhz = 0;
1253 err = -EINVAL;
1254 }
1255 } while (actual != ACCESS_ONCE(arb->actual));
1256 return err;
1257}
1258
1259int nvgpu_clk_arb_get_arbiter_effective_mhz(struct gk20a *g,
1260 u32 api_domain, u16 *freq_mhz)
1261{
1262
1263 *freq_mhz = g->ops.clk.get_rate(g, api_domain);
1264 return 0;
1265}
1266
1267int nvgpu_clk_arb_get_arbiter_clk_range(struct gk20a *g, u32 api_domain,
1268 u16 *min_mhz, u16 *max_mhz)
1269{
1270 return g->ops.clk_arb.get_arbiter_clk_range(g, api_domain,
1271 min_mhz, max_mhz);
1272}
1273
1274u32 nvgpu_clk_arb_get_arbiter_clk_domains(struct gk20a *g)
1275{
1276 return g->ops.clk_arb.get_arbiter_clk_domains(g);
1277}
1278
1279int nvgpu_clk_arb_get_arbiter_clk_f_points(struct gk20a *g,
1280 u32 api_domain, u32 *max_points, u16 *fpoints)
1281{
1282 return (int)clk_domain_get_f_points(g, api_domain, max_points, fpoints);
1283}
1284
1285static u8 nvgpu_clk_arb_find_vf_point(struct nvgpu_clk_arb *arb,
1286 u16 *gpc2clk, u16 *sys2clk, u16 *xbar2clk, u16 *mclk,
1287 u32 *voltuv, u32 *voltuv_sram, u32 *nuvmin, u32 *nuvmin_sram)
1288{
1289 u16 gpc2clk_target, mclk_target;
1290 u32 gpc2clk_voltuv, gpc2clk_voltuv_sram;
1291 u32 mclk_voltuv, mclk_voltuv_sram;
1292 u32 pstate = VF_POINT_INVALID_PSTATE;
1293 struct nvgpu_clk_vf_table *table;
1294 u32 index, index_mclk;
1295 struct nvgpu_clk_vf_point *mclk_vf = NULL;
1296
1297 do {
1298 gpc2clk_target = *gpc2clk;
1299 mclk_target = *mclk;
1300 gpc2clk_voltuv = 0;
1301 gpc2clk_voltuv_sram = 0;
1302 mclk_voltuv = 0;
1303 mclk_voltuv_sram = 0;
1304
1305 table = ACCESS_ONCE(arb->current_vf_table);
1306 /* pointer to table can be updated by callback */
1307 smp_rmb();
1308
1309 if (!table)
1310 continue;
1311 if ((!table->gpc2clk_num_points) || (!table->mclk_num_points)) {
1312 gk20a_err(dev_from_gk20a(arb->g), "found empty table");
1313 goto find_exit;
1314 }
1315 /* First we check MCLK to find out which PSTATE we are
1316 * are requesting, and from there try to find the minimum
1317 * GPC2CLK on the same PSTATE that satisfies the request.
1318 * If no GPC2CLK can be found, then we need to up the PSTATE
1319 */
1320
1321recalculate_vf_point:
1322 for (index = 0; index < table->mclk_num_points; index++) {
1323 if (table->mclk_points[index].mem_mhz >= mclk_target) {
1324 mclk_vf = &table->mclk_points[index];
1325 break;
1326 }
1327 }
1328 if (index == table->mclk_num_points) {
1329 mclk_vf = &table->mclk_points[index-1];
1330 index = table->mclk_num_points - 1;
1331 }
1332 index_mclk = index;
1333
1334 /* round up the freq requests */
1335 for (index = 0; index < table->gpc2clk_num_points; index++) {
1336 pstate = VF_POINT_COMMON_PSTATE(
1337 &table->gpc2clk_points[index], mclk_vf);
1338
1339 if ((table->gpc2clk_points[index].gpc_mhz >=
1340 gpc2clk_target) &&
1341 (pstate != VF_POINT_INVALID_PSTATE)){
1342 gpc2clk_target =
1343 table->gpc2clk_points[index].gpc_mhz;
1344 *sys2clk =
1345 table->gpc2clk_points[index].sys_mhz;
1346 *xbar2clk =
1347 table->gpc2clk_points[index].xbar_mhz;
1348
1349 gpc2clk_voltuv =
1350 table->gpc2clk_points[index].uvolt;
1351 gpc2clk_voltuv_sram =
1352 table->gpc2clk_points[index].uvolt_sram;
1353 break;
1354 }
1355 }
1356
1357 if (index == table->gpc2clk_num_points) {
1358 pstate = VF_POINT_COMMON_PSTATE(
1359 &table->gpc2clk_points[index-1], mclk_vf);
1360 if (pstate != VF_POINT_INVALID_PSTATE) {
1361 gpc2clk_target =
1362 table->gpc2clk_points[index-1].gpc_mhz;
1363 *sys2clk =
1364 table->gpc2clk_points[index-1].sys_mhz;
1365 *xbar2clk =
1366 table->gpc2clk_points[index-1].xbar_mhz;
1367
1368 gpc2clk_voltuv =
1369 table->gpc2clk_points[index-1].uvolt;
1370 gpc2clk_voltuv_sram =
1371 table->gpc2clk_points[index-1].
1372 uvolt_sram;
1373 } else if (index_mclk >= table->mclk_num_points - 1) {
1374 /* There is no available combination of MCLK
1375 * and GPC2CLK, we need to fail this
1376 */
1377 gpc2clk_target = 0;
1378 mclk_target = 0;
1379 pstate = VF_POINT_INVALID_PSTATE;
1380 goto find_exit;
1381 } else {
1382 /* recalculate with higher PSTATE */
1383 gpc2clk_target = *gpc2clk;
1384 mclk_target = table->mclk_points[index_mclk+1].
1385 mem_mhz;
1386 goto recalculate_vf_point;
1387 }
1388 }
1389
1390 mclk_target = mclk_vf->mem_mhz;
1391 mclk_voltuv = mclk_vf->uvolt;
1392 mclk_voltuv_sram = mclk_vf->uvolt_sram;
1393
1394 } while (!table ||
1395 (ACCESS_ONCE(arb->current_vf_table) != table));
1396
1397find_exit:
1398 *voltuv = gpc2clk_voltuv > mclk_voltuv ? gpc2clk_voltuv : mclk_voltuv;
1399 *voltuv_sram = gpc2clk_voltuv_sram > mclk_voltuv_sram ?
1400 gpc2clk_voltuv_sram : mclk_voltuv_sram;
1401 /* noise unaware vmin */
1402 *nuvmin = mclk_voltuv;
1403 *nuvmin_sram = mclk_voltuv_sram;
1404 *gpc2clk = gpc2clk_target;
1405 *mclk = mclk_target;
1406 return pstate;
1407}
1408
1409/* This function is inherently unsafe to call while arbiter is running
1410 * arbiter must be blocked before calling this function */
1411int nvgpu_clk_arb_get_current_pstate(struct gk20a *g)
1412{
1413 return ACCESS_ONCE(g->clk_arb->actual->pstate);
1414}
1415
1416static int nvgpu_clk_arb_change_vf_point(struct gk20a *g, u16 gpc2clk_target,
1417 u16 sys2clk_target, u16 xbar2clk_target, u16 mclk_target, u32 voltuv,
1418 u32 voltuv_sram)
1419{
1420 struct set_fll_clk fllclk;
1421 struct nvgpu_clk_arb *arb = g->clk_arb;
1422 int status;
1423
1424 fllclk.gpc2clkmhz = gpc2clk_target;
1425 fllclk.sys2clkmhz = sys2clk_target;
1426 fllclk.xbar2clkmhz = xbar2clk_target;
1427
1428 fllclk.voltuv = voltuv;
1429
1430 /* if voltage ascends we do:
1431 * (1) FLL change
1432 * (2) Voltage change
1433 * (3) MCLK change
1434 * If it goes down
1435 * (1) MCLK change
1436 * (2) Voltage change
1437 * (3) FLL change
1438 */
1439
1440 /* descending */
1441 if (voltuv < arb->voltuv_actual) {
1442 status = g->clk_pmu.clk_mclk.change(g, mclk_target);
1443 if (status < 0)
1444 return status;
1445
1446 status = volt_set_voltage(g, voltuv, voltuv_sram);
1447 if (status < 0)
1448 return status;
1449
1450 status = clk_set_fll_clks(g, &fllclk);
1451 if (status < 0)
1452 return status;
1453 } else {
1454 status = clk_set_fll_clks(g, &fllclk);
1455 if (status < 0)
1456 return status;
1457
1458 status = volt_set_voltage(g, voltuv, voltuv_sram);
1459 if (status < 0)
1460 return status;
1461
1462 status = g->clk_pmu.clk_mclk.change(g, mclk_target);
1463 if (status < 0)
1464 return status;
1465 }
1466
1467 return 0;
1468}
1469
1470void nvgpu_clk_arb_pstate_change_lock(struct gk20a *g, bool lock)
1471{
1472 struct nvgpu_clk_arb *arb = g->clk_arb;
1473
1474 if (lock)
1475 mutex_lock(&arb->pstate_lock);
1476 else
1477 mutex_unlock(&arb->pstate_lock);
1478
1479}
1480
1481#ifdef CONFIG_DEBUG_FS
1482static int nvgpu_clk_arb_stats_show(struct seq_file *s, void *unused)
1483{
1484 struct gk20a *g = s->private;
1485 struct nvgpu_clk_arb *arb = g->clk_arb;
1486 struct nvgpu_clk_arb_debug *debug;
1487
1488 u64 num;
1489 s64 tmp, avg, std, max, min;
1490
1491 debug = ACCESS_ONCE(arb->debug);
1492 /* Make copy of structure and ensure no reordering */
1493 smp_rmb();
1494 if (!debug)
1495 return -EINVAL;
1496
1497 std = debug->switch_std;
1498 avg = debug->switch_avg;
1499 max = debug->switch_max;
1500 min = debug->switch_min;
1501 num = debug->switch_num;
1502
1503 tmp = std;
1504 do_div(tmp, num);
1505 seq_printf(s, "Number of transitions: %lld\n",
1506 num);
1507 seq_printf(s, "max / min : %lld / %lld usec\n",
1508 max, min);
1509 seq_printf(s, "avg / std : %lld / %ld usec\n",
1510 avg, int_sqrt(tmp));
1511
1512 return 0;
1513}
1514
1515static int nvgpu_clk_arb_stats_open(struct inode *inode, struct file *file)
1516{
1517 return single_open(file, nvgpu_clk_arb_stats_show, inode->i_private);
1518}
1519
1520static const struct file_operations nvgpu_clk_arb_stats_fops = {
1521 .open = nvgpu_clk_arb_stats_open,
1522 .read = seq_read,
1523 .llseek = seq_lseek,
1524 .release = single_release,
1525};
1526
1527
1528static int nvgpu_clk_arb_debugfs_init(struct gk20a *g)
1529{
1530 struct gk20a_platform *platform = dev_get_drvdata(g->dev);
1531
1532 struct dentry *gpu_root = platform->debugfs;
1533 struct dentry *d;
1534
1535 gk20a_dbg(gpu_dbg_info, "g=%p", g);
1536
1537 d = debugfs_create_file(
1538 "arb_stats",
1539 S_IRUGO,
1540 gpu_root,
1541 g,
1542 &nvgpu_clk_arb_stats_fops);
1543 if (!d)
1544 return -ENOMEM;
1545
1546 return 0;
1547}
1548#endif
diff --git a/drivers/gpu/nvgpu/clk/clk_arb.h b/drivers/gpu/nvgpu/clk/clk_arb.h
new file mode 100644
index 00000000..700804b3
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_arb.h
@@ -0,0 +1,71 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15
16#ifndef _CLK_ARB_H_
17#define _CLK_ARB_H_
18
19struct nvgpu_clk_arb;
20struct nvgpu_clk_session;
21
22int nvgpu_clk_arb_init_arbiter(struct gk20a *g);
23
24int nvgpu_clk_arb_get_arbiter_clk_range(struct gk20a *g, u32 api_domain,
25 u16 *min_mhz, u16 *max_mhz);
26
27int nvgpu_clk_arb_get_arbiter_actual_mhz(struct gk20a *g,
28 u32 api_domain, u16 *actual_mhz);
29
30int nvgpu_clk_arb_get_arbiter_effective_mhz(struct gk20a *g,
31 u32 api_domain, u16 *effective_mhz);
32
33int nvgpu_clk_arb_get_arbiter_clk_f_points(struct gk20a *g,
34 u32 api_domain, u32 *max_points, u16 *fpoints);
35
36u32 nvgpu_clk_arb_get_arbiter_clk_domains(struct gk20a *g);
37
38void nvgpu_clk_arb_cleanup_arbiter(struct gk20a *g);
39
40int nvgpu_clk_arb_install_session_fd(struct gk20a *g,
41 struct nvgpu_clk_session *session);
42
43int nvgpu_clk_arb_init_session(struct gk20a *g,
44 struct nvgpu_clk_session **_session);
45
46void nvgpu_clk_arb_release_session(struct gk20a *g,
47 struct nvgpu_clk_session *session);
48
49int nvgpu_clk_arb_commit_request_fd(struct gk20a *g,
50 struct nvgpu_clk_session *session, int request_fd);
51
52int nvgpu_clk_arb_set_session_target_mhz(struct nvgpu_clk_session *session,
53 int fd, u32 api_domain, u16 target_mhz);
54
55int nvgpu_clk_arb_get_session_target_mhz(struct nvgpu_clk_session *session,
56 u32 api_domain, u16 *target_mhz);
57
58int nvgpu_clk_arb_install_event_fd(struct gk20a *g,
59 struct nvgpu_clk_session *session, int *event_fd);
60
61int nvgpu_clk_arb_install_request_fd(struct gk20a *g,
62 struct nvgpu_clk_session *session, int *event_fd);
63
64void nvgpu_clk_arb_schedule_vf_table_update(struct gk20a *g);
65
66int nvgpu_clk_arb_get_current_pstate(struct gk20a *g);
67
68void nvgpu_clk_arb_pstate_change_lock(struct gk20a *g, bool lock);
69
70#endif /* _CLK_ARB_H_ */
71
diff --git a/drivers/gpu/nvgpu/clk/clk_domain.c b/drivers/gpu/nvgpu/clk/clk_domain.c
new file mode 100644
index 00000000..fe3db5d6
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_domain.c
@@ -0,0 +1,1113 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "clk.h"
16#include "clk_fll.h"
17#include "clk_domain.h"
18#include "include/bios.h"
19#include "boardobj/boardobjgrp.h"
20#include "boardobj/boardobjgrp_e32.h"
21#include "pmuif/gpmuifboardobj.h"
22#include "pmuif/gpmuifclk.h"
23#include "gm206/bios_gm206.h"
24#include "ctrl/ctrlclk.h"
25#include "ctrl/ctrlvolt.h"
26#include "gk20a/pmu_gk20a.h"
27
28static struct clk_domain *construct_clk_domain(struct gk20a *g, void *pargs);
29
30static u32 devinit_get_clocks_table(struct gk20a *g,
31 struct clk_domains *pdomainobjs);
32
33static u32 clk_domain_pmudatainit_super(struct gk20a *g, struct boardobj
34 *board_obj_ptr, struct nv_pmu_boardobj *ppmudata);
35
36const struct vbios_clocks_table_1x_hal_clock_entry vbiosclktbl1xhalentry[] = {
37 { clkwhich_gpc2clk, true, },
38 { clkwhich_xbar2clk, true, },
39 { clkwhich_mclk, false, },
40 { clkwhich_sys2clk, true, },
41 { clkwhich_hub2clk, false, },
42 { clkwhich_nvdclk, false, },
43 { clkwhich_pwrclk, false, },
44 { clkwhich_dispclk, false, },
45 { clkwhich_pciegenclk, false, }
46};
47
48static u32 clktranslatehalmumsettoapinumset(u32 clkhaldomains)
49{
50 u32 clkapidomains = 0;
51
52 if (clkhaldomains & BIT(clkwhich_gpc2clk))
53 clkapidomains |= CTRL_CLK_DOMAIN_GPC2CLK;
54 if (clkhaldomains & BIT(clkwhich_xbar2clk))
55 clkapidomains |= CTRL_CLK_DOMAIN_XBAR2CLK;
56 if (clkhaldomains & BIT(clkwhich_sys2clk))
57 clkapidomains |= CTRL_CLK_DOMAIN_SYS2CLK;
58 if (clkhaldomains & BIT(clkwhich_hub2clk))
59 clkapidomains |= CTRL_CLK_DOMAIN_HUB2CLK;
60 if (clkhaldomains & BIT(clkwhich_pwrclk))
61 clkapidomains |= CTRL_CLK_DOMAIN_PWRCLK;
62 if (clkhaldomains & BIT(clkwhich_pciegenclk))
63 clkapidomains |= CTRL_CLK_DOMAIN_PCIEGENCLK;
64 if (clkhaldomains & BIT(clkwhich_mclk))
65 clkapidomains |= CTRL_CLK_DOMAIN_MCLK;
66 if (clkhaldomains & BIT(clkwhich_nvdclk))
67 clkapidomains |= CTRL_CLK_DOMAIN_NVDCLK;
68 if (clkhaldomains & BIT(clkwhich_dispclk))
69 clkapidomains |= CTRL_CLK_DOMAIN_DISPCLK;
70
71 return clkapidomains;
72}
73
74static u32 _clk_domains_pmudatainit_3x(struct gk20a *g,
75 struct boardobjgrp *pboardobjgrp,
76 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu)
77{
78 struct nv_pmu_clk_clk_domain_boardobjgrp_set_header *pset =
79 (struct nv_pmu_clk_clk_domain_boardobjgrp_set_header *)
80 pboardobjgrppmu;
81 struct clk_domains *pdomains = (struct clk_domains *)pboardobjgrp;
82 u32 status = 0;
83
84 status = boardobjgrp_pmudatainit_e32(g, pboardobjgrp, pboardobjgrppmu);
85 if (status) {
86 gk20a_err(dev_from_gk20a(g),
87 "error updating pmu boardobjgrp for clk domain 0x%x",
88 status);
89 goto done;
90 }
91
92 pset->vbios_domains = pdomains->vbios_domains;
93 pset->cntr_sampling_periodms = pdomains->cntr_sampling_periodms;
94 pset->b_override_o_v_o_c = false;
95 pset->b_debug_mode = false;
96 pset->b_enforce_vf_monotonicity = pdomains->b_enforce_vf_monotonicity;
97 pset->b_enforce_vf_smoothening = pdomains->b_enforce_vf_smoothening;
98 pset->volt_rails_max = 2;
99 status = boardobjgrpmask_export(
100 &pdomains->master_domains_mask.super,
101 pdomains->master_domains_mask.super.bitcount,
102 &pset->master_domains_mask.super);
103
104 memcpy(&pset->deltas, &pdomains->deltas,
105 (sizeof(struct ctrl_clk_clk_delta)));
106
107done:
108 return status;
109}
110
111static u32 _clk_domains_pmudata_instget(struct gk20a *g,
112 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
113 struct nv_pmu_boardobj **ppboardobjpmudata,
114 u8 idx)
115{
116 struct nv_pmu_clk_clk_domain_boardobj_grp_set *pgrp_set =
117 (struct nv_pmu_clk_clk_domain_boardobj_grp_set *)
118 pmuboardobjgrp;
119
120 gk20a_dbg_info("");
121
122 /*check whether pmuboardobjgrp has a valid boardobj in index*/
123 if (((u32)BIT(idx) &
124 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
125 return -EINVAL;
126
127 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
128 &pgrp_set->objects[idx].data.board_obj;
129 gk20a_dbg_info(" Done");
130 return 0;
131}
132
133u32 clk_domain_sw_setup(struct gk20a *g)
134{
135 u32 status;
136 struct boardobjgrp *pboardobjgrp = NULL;
137 struct clk_domains *pclkdomainobjs;
138 struct clk_domain *pdomain;
139 struct clk_domain_3x_master *pdomain_master;
140 struct clk_domain_3x_slave *pdomain_slave;
141 u8 i;
142
143 gk20a_dbg_info("");
144
145 status = boardobjgrpconstruct_e32(&g->clk_pmu.clk_domainobjs.super);
146 if (status) {
147 gk20a_err(dev_from_gk20a(g),
148 "error creating boardobjgrp for clk domain, status - 0x%x",
149 status);
150 goto done;
151 }
152
153 pboardobjgrp = &g->clk_pmu.clk_domainobjs.super.super;
154 pclkdomainobjs = &(g->clk_pmu.clk_domainobjs);
155
156 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, CLK, CLK_DOMAIN);
157
158 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
159 clk, CLK, clk_domain, CLK_DOMAIN);
160 if (status) {
161 gk20a_err(dev_from_gk20a(g),
162 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
163 status);
164 goto done;
165 }
166
167 pboardobjgrp->pmudatainit = _clk_domains_pmudatainit_3x;
168 pboardobjgrp->pmudatainstget = _clk_domains_pmudata_instget;
169
170 /* Initialize mask to zero.*/
171 boardobjgrpmask_e32_init(&pclkdomainobjs->prog_domains_mask, NULL);
172 boardobjgrpmask_e32_init(&pclkdomainobjs->master_domains_mask, NULL);
173 pclkdomainobjs->b_enforce_vf_monotonicity = true;
174 pclkdomainobjs->b_enforce_vf_smoothening = true;
175
176 memset(&pclkdomainobjs->ordered_noise_aware_list, 0,
177 sizeof(pclkdomainobjs->ordered_noise_aware_list));
178
179 memset(&pclkdomainobjs->ordered_noise_unaware_list, 0,
180 sizeof(pclkdomainobjs->ordered_noise_unaware_list));
181
182 memset(&pclkdomainobjs->deltas, 0,
183 sizeof(struct ctrl_clk_clk_delta));
184
185 status = devinit_get_clocks_table(g, pclkdomainobjs);
186 if (status)
187 goto done;
188
189 BOARDOBJGRP_FOR_EACH(&(pclkdomainobjs->super.super),
190 struct clk_domain *, pdomain, i) {
191 pdomain_master = NULL;
192 if (pdomain->super.implements(g, &pdomain->super,
193 CTRL_CLK_CLK_DOMAIN_TYPE_3X_PROG)) {
194 status = boardobjgrpmask_bitset(
195 &pclkdomainobjs->prog_domains_mask.super, i);
196 if (status)
197 goto done;
198 }
199
200 if (pdomain->super.implements(g, &pdomain->super,
201 CTRL_CLK_CLK_DOMAIN_TYPE_3X_MASTER)) {
202 status = boardobjgrpmask_bitset(
203 &pclkdomainobjs->master_domains_mask.super, i);
204 if (status)
205 goto done;
206 }
207
208 if (pdomain->super.implements(g, &pdomain->super,
209 CTRL_CLK_CLK_DOMAIN_TYPE_3X_SLAVE)) {
210 pdomain_slave =
211 (struct clk_domain_3x_slave *)pdomain;
212 pdomain_master =
213 (struct clk_domain_3x_master *)
214 (CLK_CLK_DOMAIN_GET((&g->clk_pmu),
215 pdomain_slave->master_idx));
216 pdomain_master->slave_idxs_mask |= BIT(i);
217 }
218
219 }
220
221done:
222 gk20a_dbg_info(" done status %x", status);
223 return status;
224}
225
226u32 clk_domain_pmu_setup(struct gk20a *g)
227{
228 u32 status;
229 struct boardobjgrp *pboardobjgrp = NULL;
230
231 gk20a_dbg_info("");
232
233 pboardobjgrp = &g->clk_pmu.clk_domainobjs.super.super;
234
235 if (!pboardobjgrp->bconstructed)
236 return -EINVAL;
237
238 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
239
240 gk20a_dbg_info("Done");
241 return status;
242}
243
244static u32 devinit_get_clocks_table(struct gk20a *g,
245 struct clk_domains *pclkdomainobjs)
246{
247 u32 status = 0;
248 u8 *clocks_table_ptr = NULL;
249 struct vbios_clocks_table_1x_header clocks_table_header = { 0 };
250 struct vbios_clocks_table_1x_entry clocks_table_entry = { 0 };
251 u8 *clocks_tbl_entry_ptr = NULL;
252 u32 index = 0;
253 struct clk_domain *pclkdomain_dev;
254 union {
255 struct boardobj boardobj;
256 struct clk_domain clk_domain;
257 struct clk_domain_3x v3x;
258 struct clk_domain_3x_fixed v3x_fixed;
259 struct clk_domain_3x_prog v3x_prog;
260 struct clk_domain_3x_master v3x_master;
261 struct clk_domain_3x_slave v3x_slave;
262 } clk_domain_data;
263
264 gk20a_dbg_info("");
265
266 if (g->ops.bios.get_perf_table_ptrs) {
267 clocks_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
268 g->bios.clock_token, CLOCKS_TABLE);
269 if (clocks_table_ptr == NULL) {
270 status = -EINVAL;
271 goto done;
272 }
273 }
274
275 memcpy(&clocks_table_header, clocks_table_ptr,
276 VBIOS_CLOCKS_TABLE_1X_HEADER_SIZE_07);
277 if (clocks_table_header.header_size <
278 VBIOS_CLOCKS_TABLE_1X_HEADER_SIZE_07) {
279 status = -EINVAL;
280 goto done;
281 }
282
283 if (clocks_table_header.entry_size <
284 VBIOS_CLOCKS_TABLE_1X_ENTRY_SIZE_09) {
285 status = -EINVAL;
286 goto done;
287 }
288
289 pclkdomainobjs->cntr_sampling_periodms =
290 (u16)clocks_table_header.cntr_sampling_periodms;
291
292 /* Read table entries*/
293 clocks_tbl_entry_ptr = clocks_table_ptr +
294 VBIOS_CLOCKS_TABLE_1X_HEADER_SIZE_07;
295 for (index = 0; index < clocks_table_header.entry_count; index++) {
296 memcpy(&clocks_table_entry, clocks_tbl_entry_ptr,
297 clocks_table_header.entry_size);
298 clk_domain_data.clk_domain.domain =
299 vbiosclktbl1xhalentry[index].domain;
300 clk_domain_data.clk_domain.api_domain =
301 clktranslatehalmumsettoapinumset(
302 BIT(clk_domain_data.clk_domain.domain));
303 clk_domain_data.v3x.b_noise_aware_capable =
304 vbiosclktbl1xhalentry[index].b_noise_aware_capable;
305
306 switch (BIOS_GET_FIELD(clocks_table_entry.flags0,
307 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_FLAGS0_USAGE)) {
308 case NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_FLAGS0_USAGE_FIXED:
309 clk_domain_data.boardobj.type =
310 CTRL_CLK_CLK_DOMAIN_TYPE_3X_FIXED;
311 clk_domain_data.v3x_fixed.freq_mhz = (u16)BIOS_GET_FIELD(
312 clocks_table_entry.param1,
313 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_FIXED_FREQUENCY_MHZ);
314 break;
315
316 case NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_FLAGS0_USAGE_MASTER:
317 clk_domain_data.boardobj.type =
318 CTRL_CLK_CLK_DOMAIN_TYPE_3X_MASTER;
319 clk_domain_data.v3x_prog.clk_prog_idx_first =
320 (u8)(BIOS_GET_FIELD(clocks_table_entry.param0,
321 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM0_PROG_CLK_PROG_IDX_FIRST));
322 clk_domain_data.v3x_prog.clk_prog_idx_last =
323 (u8)(BIOS_GET_FIELD(clocks_table_entry.param0,
324 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM0_PROG_CLK_PROG_IDX_LAST));
325 clk_domain_data.v3x_prog.noise_unaware_ordering_index =
326 (u8)(BIOS_GET_FIELD(clocks_table_entry.param2,
327 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_NOISE_UNAWARE_ORDERING_IDX));
328
329 if (clk_domain_data.v3x.b_noise_aware_capable) {
330 clk_domain_data.v3x_prog.noise_aware_ordering_index =
331 (u8)(BIOS_GET_FIELD(clocks_table_entry.param2,
332 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_NOISE_AWARE_ORDERING_IDX));
333 clk_domain_data.v3x_prog.b_force_noise_unaware_ordering =
334 (u8)(BIOS_GET_FIELD(clocks_table_entry.param2,
335 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_FORCE_NOISE_UNAWARE_ORDERING));
336 } else {
337 clk_domain_data.v3x_prog.noise_aware_ordering_index =
338 CTRL_CLK_CLK_DOMAIN_3X_PROG_ORDERING_INDEX_INVALID;
339 clk_domain_data.v3x_prog.b_force_noise_unaware_ordering = false;
340 }
341 clk_domain_data.v3x_prog.factory_offset_khz = 0;
342
343 clk_domain_data.v3x_prog.freq_delta_min_mhz =
344 (u16)(BIOS_GET_FIELD(clocks_table_entry.param1,
345 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_MASTER_FREQ_OC_DELTA_MIN_MHZ));
346
347 clk_domain_data.v3x_prog.freq_delta_max_mhz =
348 (u16)(BIOS_GET_FIELD(clocks_table_entry.param1,
349 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_MASTER_FREQ_OC_DELTA_MAX_MHZ));
350 break;
351
352 case NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_FLAGS0_USAGE_SLAVE:
353 clk_domain_data.boardobj.type =
354 CTRL_CLK_CLK_DOMAIN_TYPE_3X_SLAVE;
355 clk_domain_data.v3x_prog.clk_prog_idx_first =
356 (u8)(BIOS_GET_FIELD(clocks_table_entry.param0,
357 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM0_PROG_CLK_PROG_IDX_FIRST));
358 clk_domain_data.v3x_prog.clk_prog_idx_last =
359 (u8)(BIOS_GET_FIELD(clocks_table_entry.param0,
360 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM0_PROG_CLK_PROG_IDX_LAST));
361 clk_domain_data.v3x_prog.noise_unaware_ordering_index =
362 (u8)(BIOS_GET_FIELD(clocks_table_entry.param2,
363 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_NOISE_UNAWARE_ORDERING_IDX));
364
365 if (clk_domain_data.v3x.b_noise_aware_capable) {
366 clk_domain_data.v3x_prog.noise_aware_ordering_index =
367 (u8)(BIOS_GET_FIELD(clocks_table_entry.param2,
368 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_NOISE_AWARE_ORDERING_IDX));
369 clk_domain_data.v3x_prog.b_force_noise_unaware_ordering =
370 (u8)(BIOS_GET_FIELD(clocks_table_entry.param2,
371 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_FORCE_NOISE_UNAWARE_ORDERING));
372 } else {
373 clk_domain_data.v3x_prog.noise_aware_ordering_index =
374 CTRL_CLK_CLK_DOMAIN_3X_PROG_ORDERING_INDEX_INVALID;
375 clk_domain_data.v3x_prog.b_force_noise_unaware_ordering = false;
376 }
377 clk_domain_data.v3x_prog.factory_offset_khz = 0;
378 clk_domain_data.v3x_prog.freq_delta_min_mhz = 0;
379 clk_domain_data.v3x_prog.freq_delta_max_mhz = 0;
380 clk_domain_data.v3x_slave.master_idx =
381 (u8)(BIOS_GET_FIELD(clocks_table_entry.param1,
382 NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_SLAVE_MASTER_DOMAIN));
383 break;
384
385 default:
386 gk20a_err(dev_from_gk20a(g),
387 "error reading clock domain entry %d", index);
388 status = -EINVAL;
389 goto done;
390
391 }
392 pclkdomain_dev = construct_clk_domain(g,
393 (void *)&clk_domain_data);
394 if (pclkdomain_dev == NULL) {
395 gk20a_err(dev_from_gk20a(g),
396 "unable to construct clock domain boardobj for %d",
397 index);
398 status = -EINVAL;
399 goto done;
400 }
401 status = boardobjgrp_objinsert(&pclkdomainobjs->super.super,
402 (struct boardobj *)pclkdomain_dev, index);
403 if (status) {
404 gk20a_err(dev_from_gk20a(g),
405 "unable to insert clock domain boardobj for %d", index);
406 status = -EINVAL;
407 goto done;
408 }
409 clocks_tbl_entry_ptr += clocks_table_header.entry_size;
410 }
411
412done:
413 gk20a_dbg_info(" done status %x", status);
414 return status;
415}
416
417static u32 clkdomainclkproglink_not_supported(struct gk20a *g,
418 struct clk_pmupstate *pclk,
419 struct clk_domain *pdomain)
420{
421 gk20a_dbg_info("");
422 return -EINVAL;
423}
424
425static int clkdomainvfsearch_stub(
426 struct gk20a *g,
427 struct clk_pmupstate *pclk,
428 struct clk_domain *pdomain,
429 u16 *clkmhz,
430 u32 *voltuv,
431 u8 rail)
432
433{
434 gk20a_dbg_info("");
435 return -EINVAL;
436}
437
438static u32 clkdomaingetfpoints_stub(
439 struct gk20a *g,
440 struct clk_pmupstate *pclk,
441 struct clk_domain *pdomain,
442 u32 *pfpointscount,
443 u16 *pfreqpointsinmhz,
444 u8 rail)
445{
446 gk20a_dbg_info("");
447 return -EINVAL;
448}
449
450
451static u32 clk_domain_construct_super(struct gk20a *g,
452 struct boardobj **ppboardobj,
453 u16 size, void *pargs)
454{
455 struct clk_domain *pdomain;
456 struct clk_domain *ptmpdomain = (struct clk_domain *)pargs;
457 u32 status = 0;
458
459 status = boardobj_construct_super(g, ppboardobj,
460 size, pargs);
461
462 if (status)
463 return -EINVAL;
464
465 pdomain = (struct clk_domain *)*ppboardobj;
466
467 pdomain->super.pmudatainit =
468 clk_domain_pmudatainit_super;
469
470 pdomain->clkdomainclkproglink =
471 clkdomainclkproglink_not_supported;
472
473 pdomain->clkdomainclkvfsearch =
474 clkdomainvfsearch_stub;
475
476 pdomain->clkdomainclkgetfpoints =
477 clkdomaingetfpoints_stub;
478
479 pdomain->api_domain = ptmpdomain->api_domain;
480 pdomain->domain = ptmpdomain->domain;
481 pdomain->perf_domain_grp_idx =
482 ptmpdomain->perf_domain_grp_idx;
483
484 return status;
485}
486
487static u32 _clk_domain_pmudatainit_3x(struct gk20a *g,
488 struct boardobj *board_obj_ptr,
489 struct nv_pmu_boardobj *ppmudata)
490{
491 u32 status = 0;
492 struct clk_domain_3x *pclk_domain_3x;
493 struct nv_pmu_clk_clk_domain_3x_boardobj_set *pset;
494
495 gk20a_dbg_info("");
496
497 status = clk_domain_pmudatainit_super(g, board_obj_ptr, ppmudata);
498 if (status != 0)
499 return status;
500
501 pclk_domain_3x = (struct clk_domain_3x *)board_obj_ptr;
502
503 pset = (struct nv_pmu_clk_clk_domain_3x_boardobj_set *)ppmudata;
504
505 pset->b_noise_aware_capable = pclk_domain_3x->b_noise_aware_capable;
506
507 return status;
508}
509
510static u32 clk_domain_construct_3x(struct gk20a *g,
511 struct boardobj **ppboardobj,
512 u16 size, void *pargs)
513{
514 struct boardobj *ptmpobj = (struct boardobj *)pargs;
515 struct clk_domain_3x *pdomain;
516 struct clk_domain_3x *ptmpdomain =
517 (struct clk_domain_3x *)pargs;
518 u32 status = 0;
519
520 ptmpobj->type_mask = BIT(CTRL_CLK_CLK_DOMAIN_TYPE_3X);
521 status = clk_domain_construct_super(g, ppboardobj,
522 size, pargs);
523 if (status)
524 return -EINVAL;
525
526 pdomain = (struct clk_domain_3x *)*ppboardobj;
527
528 pdomain->super.super.pmudatainit =
529 _clk_domain_pmudatainit_3x;
530
531 pdomain->b_noise_aware_capable = ptmpdomain->b_noise_aware_capable;
532
533 return status;
534}
535
536static u32 clkdomainclkproglink_3x_prog(struct gk20a *g,
537 struct clk_pmupstate *pclk,
538 struct clk_domain *pdomain)
539{
540 u32 status = 0;
541 struct clk_domain_3x_prog *p3xprog =
542 (struct clk_domain_3x_prog *)pdomain;
543 struct clk_prog *pprog = NULL;
544 u8 i;
545
546 gk20a_dbg_info("");
547
548 for (i = p3xprog->clk_prog_idx_first;
549 i <= p3xprog->clk_prog_idx_last;
550 i++) {
551 pprog = CLK_CLK_PROG_GET(pclk, i);
552 if (pprog == NULL)
553 status = -EINVAL;
554 }
555 return status;
556}
557
558static int clkdomaingetslaveclk(struct gk20a *g,
559 struct clk_pmupstate *pclk,
560 struct clk_domain *pdomain,
561 u16 *pclkmhz,
562 u16 masterclkmhz)
563{
564 int status = 0;
565 struct clk_prog *pprog = NULL;
566 struct clk_prog_1x_master *pprog1xmaster = NULL;
567 u8 slaveidx;
568 struct clk_domain_3x_master *p3xmaster;
569
570 gk20a_dbg_info("");
571
572 if (pclkmhz == NULL)
573 return -EINVAL;
574
575 if (masterclkmhz == 0)
576 return -EINVAL;
577
578 slaveidx = BOARDOBJ_GET_IDX(pdomain);
579 p3xmaster = (struct clk_domain_3x_master *)
580 CLK_CLK_DOMAIN_GET(pclk,
581 ((struct clk_domain_3x_slave *)
582 pdomain)->master_idx);
583 pprog = CLK_CLK_PROG_GET(pclk, p3xmaster->super.clk_prog_idx_first);
584 pprog1xmaster = (struct clk_prog_1x_master *)pprog;
585
586 status = pprog1xmaster->getslaveclk(g, pclk, pprog1xmaster,
587 slaveidx, pclkmhz, masterclkmhz);
588 return status;
589}
590
591static int clkdomainvfsearch(struct gk20a *g,
592 struct clk_pmupstate *pclk,
593 struct clk_domain *pdomain,
594 u16 *pclkmhz,
595 u32 *pvoltuv,
596 u8 rail)
597{
598 int status = 0;
599 struct clk_domain_3x_master *p3xmaster =
600 (struct clk_domain_3x_master *)pdomain;
601 struct clk_prog *pprog = NULL;
602 struct clk_prog_1x_master *pprog1xmaster = NULL;
603 u8 i;
604 u8 *pslaveidx = NULL;
605 u8 slaveidx;
606 u16 clkmhz;
607 u32 voltuv;
608 u16 bestclkmhz;
609 u32 bestvoltuv;
610
611 gk20a_dbg_info("");
612
613 if ((pclkmhz == NULL) || (pvoltuv == NULL))
614 return -EINVAL;
615
616 if ((*pclkmhz != 0) && (*pvoltuv != 0))
617 return -EINVAL;
618
619 bestclkmhz = *pclkmhz;
620 bestvoltuv = *pvoltuv;
621
622 if (pdomain->super.implements(g, &pdomain->super,
623 CTRL_CLK_CLK_DOMAIN_TYPE_3X_SLAVE)) {
624 slaveidx = BOARDOBJ_GET_IDX(pdomain);
625 pslaveidx = &slaveidx;
626 p3xmaster = (struct clk_domain_3x_master *)
627 CLK_CLK_DOMAIN_GET(pclk,
628 ((struct clk_domain_3x_slave *)
629 pdomain)->master_idx);
630 }
631 /* Iterate over the set of CLK_PROGs pointed at by this domain.*/
632 for (i = p3xmaster->super.clk_prog_idx_first;
633 i <= p3xmaster->super.clk_prog_idx_last;
634 i++) {
635 clkmhz = *pclkmhz;
636 voltuv = *pvoltuv;
637 pprog = CLK_CLK_PROG_GET(pclk, i);
638
639 /* MASTER CLK_DOMAINs must point to MASTER CLK_PROGs.*/
640 if (!pprog->super.implements(g, &pprog->super,
641 CTRL_CLK_CLK_PROG_TYPE_1X_MASTER)) {
642 status = -EINVAL;
643 goto done;
644 }
645
646 pprog1xmaster = (struct clk_prog_1x_master *)pprog;
647 status = pprog1xmaster->vflookup(g, pclk, pprog1xmaster,
648 pslaveidx, &clkmhz, &voltuv, rail);
649 /* if look up has found the V or F value matching to other
650 exit */
651 if (status == 0) {
652 if (*pclkmhz == 0) {
653 bestclkmhz = clkmhz;
654 } else {
655 bestvoltuv = voltuv;
656 break;
657 }
658 }
659 }
660 /* clk and volt sent as zero to print vf table */
661 if ((*pclkmhz == 0) && (*pvoltuv == 0)) {
662 status = 0;
663 goto done;
664 }
665 /* atleast one search found a matching value? */
666 if ((bestvoltuv != 0) && (bestclkmhz != 0)) {
667 *pclkmhz = bestclkmhz;
668 *pvoltuv = bestvoltuv;
669 status = 0;
670 goto done;
671 }
672done:
673 gk20a_dbg_info("done status %x", status);
674 return status;
675}
676
677static u32 clkdomaingetfpoints
678(
679 struct gk20a *g,
680 struct clk_pmupstate *pclk,
681 struct clk_domain *pdomain,
682 u32 *pfpointscount,
683 u16 *pfreqpointsinmhz,
684 u8 rail
685)
686{
687 u32 status = 0;
688 struct clk_domain_3x_master *p3xmaster =
689 (struct clk_domain_3x_master *)pdomain;
690 struct clk_prog *pprog = NULL;
691 struct clk_prog_1x_master *pprog1xmaster = NULL;
692 u32 fpointscount = 0;
693 u32 remainingcount;
694 u32 totalcount;
695 u16 *freqpointsdata;
696 u8 i;
697
698 gk20a_dbg_info("");
699
700 if (pfpointscount == NULL)
701 return -EINVAL;
702
703 if ((pfreqpointsinmhz == NULL) && (*pfpointscount != 0))
704 return -EINVAL;
705
706 if (pdomain->super.implements(g, &pdomain->super,
707 CTRL_CLK_CLK_DOMAIN_TYPE_3X_SLAVE))
708 return -EINVAL;
709
710 freqpointsdata = pfreqpointsinmhz;
711 totalcount = 0;
712 fpointscount = *pfpointscount;
713 remainingcount = fpointscount;
714 /* Iterate over the set of CLK_PROGs pointed at by this domain.*/
715 for (i = p3xmaster->super.clk_prog_idx_first;
716 i <= p3xmaster->super.clk_prog_idx_last;
717 i++) {
718 pprog = CLK_CLK_PROG_GET(pclk, i);
719 pprog1xmaster = (struct clk_prog_1x_master *)pprog;
720 status = pprog1xmaster->getfpoints(g, pclk, pprog1xmaster,
721 &fpointscount, &freqpointsdata, rail);
722 if (status) {
723 *pfpointscount = 0;
724 goto done;
725 }
726 totalcount += fpointscount;
727 if (*pfpointscount) {
728 remainingcount -= fpointscount;
729 fpointscount = remainingcount;
730 } else
731 fpointscount = 0;
732
733 }
734
735 *pfpointscount = totalcount;
736done:
737 gk20a_dbg_info("done status %x", status);
738 return status;
739}
740
741static u32 _clk_domain_pmudatainit_3x_prog(struct gk20a *g,
742 struct boardobj *board_obj_ptr,
743 struct nv_pmu_boardobj *ppmudata)
744{
745 u32 status = 0;
746 struct clk_domain_3x_prog *pclk_domain_3x_prog;
747 struct nv_pmu_clk_clk_domain_3x_prog_boardobj_set *pset;
748 struct clk_domains *pdomains = &(g->clk_pmu.clk_domainobjs);
749
750 gk20a_dbg_info("");
751
752 status = _clk_domain_pmudatainit_3x(g, board_obj_ptr, ppmudata);
753 if (status != 0)
754 return status;
755
756 pclk_domain_3x_prog = (struct clk_domain_3x_prog *)board_obj_ptr;
757
758 pset = (struct nv_pmu_clk_clk_domain_3x_prog_boardobj_set *)
759 ppmudata;
760
761 pset->clk_prog_idx_first = pclk_domain_3x_prog->clk_prog_idx_first;
762 pset->clk_prog_idx_last = pclk_domain_3x_prog->clk_prog_idx_last;
763 pset->noise_unaware_ordering_index =
764 pclk_domain_3x_prog->noise_unaware_ordering_index;
765 pset->noise_aware_ordering_index =
766 pclk_domain_3x_prog->noise_aware_ordering_index;
767 pset->b_force_noise_unaware_ordering =
768 pclk_domain_3x_prog->b_force_noise_unaware_ordering;
769 pset->factory_offset_khz = pclk_domain_3x_prog->factory_offset_khz;
770 pset->freq_delta_min_mhz = pclk_domain_3x_prog->freq_delta_min_mhz;
771 pset->freq_delta_max_mhz = pclk_domain_3x_prog->freq_delta_max_mhz;
772 memcpy(&pset->deltas, &pdomains->deltas,
773 (sizeof(struct ctrl_clk_clk_delta)));
774
775 return status;
776}
777
778static u32 clk_domain_construct_3x_prog(struct gk20a *g,
779 struct boardobj **ppboardobj,
780 u16 size, void *pargs)
781{
782 struct boardobj *ptmpobj = (struct boardobj *)pargs;
783 struct clk_domain_3x_prog *pdomain;
784 struct clk_domain_3x_prog *ptmpdomain =
785 (struct clk_domain_3x_prog *)pargs;
786 u32 status = 0;
787
788 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_DOMAIN_TYPE_3X_PROG);
789 status = clk_domain_construct_3x(g, ppboardobj, size, pargs);
790 if (status)
791 return -EINVAL;
792
793 pdomain = (struct clk_domain_3x_prog *)*ppboardobj;
794
795 pdomain->super.super.super.pmudatainit =
796 _clk_domain_pmudatainit_3x_prog;
797
798 pdomain->super.super.clkdomainclkproglink =
799 clkdomainclkproglink_3x_prog;
800
801 pdomain->super.super.clkdomainclkvfsearch =
802 clkdomainvfsearch;
803
804 pdomain->super.super.clkdomainclkgetfpoints =
805 clkdomaingetfpoints;
806
807 pdomain->clk_prog_idx_first = ptmpdomain->clk_prog_idx_first;
808 pdomain->clk_prog_idx_last = ptmpdomain->clk_prog_idx_last;
809 pdomain->noise_unaware_ordering_index =
810 ptmpdomain->noise_unaware_ordering_index;
811 pdomain->noise_aware_ordering_index =
812 ptmpdomain->noise_aware_ordering_index;
813 pdomain->b_force_noise_unaware_ordering =
814 ptmpdomain->b_force_noise_unaware_ordering;
815 pdomain->factory_offset_khz = ptmpdomain->factory_offset_khz;
816 pdomain->freq_delta_min_mhz = ptmpdomain->freq_delta_min_mhz;
817 pdomain->freq_delta_max_mhz = ptmpdomain->freq_delta_max_mhz;
818
819 return status;
820}
821
822static u32 _clk_domain_pmudatainit_3x_slave(struct gk20a *g,
823 struct boardobj *board_obj_ptr,
824 struct nv_pmu_boardobj *ppmudata)
825{
826 u32 status = 0;
827 struct clk_domain_3x_slave *pclk_domain_3x_slave;
828 struct nv_pmu_clk_clk_domain_3x_slave_boardobj_set *pset;
829
830 gk20a_dbg_info("");
831
832 status = _clk_domain_pmudatainit_3x_prog(g, board_obj_ptr, ppmudata);
833 if (status != 0)
834 return status;
835
836 pclk_domain_3x_slave = (struct clk_domain_3x_slave *)board_obj_ptr;
837
838 pset = (struct nv_pmu_clk_clk_domain_3x_slave_boardobj_set *)
839 ppmudata;
840
841 pset->master_idx = pclk_domain_3x_slave->master_idx;
842
843 return status;
844}
845
846static u32 clk_domain_construct_3x_slave(struct gk20a *g,
847 struct boardobj **ppboardobj,
848 u16 size, void *pargs)
849{
850 struct boardobj *ptmpobj = (struct boardobj *)pargs;
851 struct clk_domain_3x_slave *pdomain;
852 struct clk_domain_3x_slave *ptmpdomain =
853 (struct clk_domain_3x_slave *)pargs;
854 u32 status = 0;
855
856 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_DOMAIN_TYPE_3X_SLAVE)
857 return -EINVAL;
858
859 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_DOMAIN_TYPE_3X_SLAVE);
860 status = clk_domain_construct_3x_prog(g, ppboardobj, size, pargs);
861 if (status)
862 return -EINVAL;
863
864 pdomain = (struct clk_domain_3x_slave *)*ppboardobj;
865
866 pdomain->super.super.super.super.pmudatainit =
867 _clk_domain_pmudatainit_3x_slave;
868
869 pdomain->master_idx = ptmpdomain->master_idx;
870
871 pdomain->clkdomainclkgetslaveclk =
872 clkdomaingetslaveclk;
873
874 return status;
875}
876
877static u32 clkdomainclkproglink_3x_master(struct gk20a *g,
878 struct clk_pmupstate *pclk,
879 struct clk_domain *pdomain)
880{
881 u32 status = 0;
882 struct clk_domain_3x_master *p3xmaster =
883 (struct clk_domain_3x_master *)pdomain;
884 struct clk_prog *pprog = NULL;
885 struct clk_prog_1x_master *pprog1xmaster = NULL;
886 u16 freq_max_last_mhz = 0;
887 u8 i;
888
889 gk20a_dbg_info("");
890
891 status = clkdomainclkproglink_3x_prog(g, pclk, pdomain);
892 if (status)
893 goto done;
894
895 /* Iterate over the set of CLK_PROGs pointed at by this domain.*/
896 for (i = p3xmaster->super.clk_prog_idx_first;
897 i <= p3xmaster->super.clk_prog_idx_last;
898 i++) {
899 pprog = CLK_CLK_PROG_GET(pclk, i);
900
901 /* MASTER CLK_DOMAINs must point to MASTER CLK_PROGs.*/
902 if (!pprog->super.implements(g, &pprog->super,
903 CTRL_CLK_CLK_PROG_TYPE_1X_MASTER)) {
904 status = -EINVAL;
905 goto done;
906 }
907
908 pprog1xmaster = (struct clk_prog_1x_master *)pprog;
909 status = pprog1xmaster->vfflatten(g, pclk, pprog1xmaster,
910 BOARDOBJ_GET_IDX(p3xmaster), &freq_max_last_mhz);
911 if (status)
912 goto done;
913 }
914done:
915 gk20a_dbg_info("done status %x", status);
916 return status;
917}
918
919static u32 _clk_domain_pmudatainit_3x_master(struct gk20a *g,
920 struct boardobj *board_obj_ptr,
921 struct nv_pmu_boardobj *ppmudata)
922{
923 u32 status = 0;
924 struct clk_domain_3x_master *pclk_domain_3x_master;
925 struct nv_pmu_clk_clk_domain_3x_master_boardobj_set *pset;
926
927 gk20a_dbg_info("");
928
929 status = _clk_domain_pmudatainit_3x_prog(g, board_obj_ptr, ppmudata);
930 if (status != 0)
931 return status;
932
933 pclk_domain_3x_master = (struct clk_domain_3x_master *)board_obj_ptr;
934
935 pset = (struct nv_pmu_clk_clk_domain_3x_master_boardobj_set *)
936 ppmudata;
937
938 pset->slave_idxs_mask = pclk_domain_3x_master->slave_idxs_mask;
939
940 return status;
941}
942
943static u32 clk_domain_construct_3x_master(struct gk20a *g,
944 struct boardobj **ppboardobj,
945 u16 size, void *pargs)
946{
947 struct boardobj *ptmpobj = (struct boardobj *)pargs;
948 struct clk_domain_3x_master *pdomain;
949 u32 status = 0;
950
951 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_DOMAIN_TYPE_3X_MASTER)
952 return -EINVAL;
953
954 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_DOMAIN_TYPE_3X_MASTER);
955 status = clk_domain_construct_3x_prog(g, ppboardobj, size, pargs);
956 if (status)
957 return -EINVAL;
958
959 pdomain = (struct clk_domain_3x_master *)*ppboardobj;
960
961 pdomain->super.super.super.super.pmudatainit =
962 _clk_domain_pmudatainit_3x_master;
963 pdomain->super.super.super.clkdomainclkproglink =
964 clkdomainclkproglink_3x_master;
965
966 pdomain->slave_idxs_mask = 0;
967
968 return status;
969}
970
971static u32 clkdomainclkproglink_fixed(struct gk20a *g,
972 struct clk_pmupstate *pclk,
973 struct clk_domain *pdomain)
974{
975 gk20a_dbg_info("");
976 return 0;
977}
978
979static u32 _clk_domain_pmudatainit_3x_fixed(struct gk20a *g,
980 struct boardobj *board_obj_ptr,
981 struct nv_pmu_boardobj *ppmudata)
982{
983 u32 status = 0;
984 struct clk_domain_3x_fixed *pclk_domain_3x_fixed;
985 struct nv_pmu_clk_clk_domain_3x_fixed_boardobj_set *pset;
986
987 gk20a_dbg_info("");
988
989 status = _clk_domain_pmudatainit_3x(g, board_obj_ptr, ppmudata);
990 if (status != 0)
991 return status;
992
993 pclk_domain_3x_fixed = (struct clk_domain_3x_fixed *)board_obj_ptr;
994
995 pset = (struct nv_pmu_clk_clk_domain_3x_fixed_boardobj_set *)
996 ppmudata;
997
998 pset->freq_mhz = pclk_domain_3x_fixed->freq_mhz;
999
1000 return status;
1001}
1002
1003static u32 clk_domain_construct_3x_fixed(struct gk20a *g,
1004 struct boardobj **ppboardobj,
1005 u16 size, void *pargs)
1006{
1007 struct boardobj *ptmpobj = (struct boardobj *)pargs;
1008 struct clk_domain_3x_fixed *pdomain;
1009 struct clk_domain_3x_fixed *ptmpdomain =
1010 (struct clk_domain_3x_fixed *)pargs;
1011 u32 status = 0;
1012
1013 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_DOMAIN_TYPE_3X_FIXED)
1014 return -EINVAL;
1015
1016 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_DOMAIN_TYPE_3X_FIXED);
1017 status = clk_domain_construct_3x(g, ppboardobj, size, pargs);
1018 if (status)
1019 return -EINVAL;
1020
1021 pdomain = (struct clk_domain_3x_fixed *)*ppboardobj;
1022
1023 pdomain->super.super.super.pmudatainit =
1024 _clk_domain_pmudatainit_3x_fixed;
1025
1026 pdomain->super.super.clkdomainclkproglink =
1027 clkdomainclkproglink_fixed;
1028
1029 pdomain->freq_mhz = ptmpdomain->freq_mhz;
1030
1031 return status;
1032}
1033
1034static struct clk_domain *construct_clk_domain(struct gk20a *g, void *pargs)
1035{
1036 struct boardobj *board_obj_ptr = NULL;
1037 u32 status;
1038
1039 gk20a_dbg_info(" %d", BOARDOBJ_GET_TYPE(pargs));
1040 switch (BOARDOBJ_GET_TYPE(pargs)) {
1041 case CTRL_CLK_CLK_DOMAIN_TYPE_3X_FIXED:
1042 status = clk_domain_construct_3x_fixed(g, &board_obj_ptr,
1043 sizeof(struct clk_domain_3x_fixed), pargs);
1044 break;
1045
1046 case CTRL_CLK_CLK_DOMAIN_TYPE_3X_MASTER:
1047 status = clk_domain_construct_3x_master(g, &board_obj_ptr,
1048 sizeof(struct clk_domain_3x_master), pargs);
1049 break;
1050
1051 case CTRL_CLK_CLK_DOMAIN_TYPE_3X_SLAVE:
1052 status = clk_domain_construct_3x_slave(g, &board_obj_ptr,
1053 sizeof(struct clk_domain_3x_slave), pargs);
1054 break;
1055
1056 default:
1057 return NULL;
1058 }
1059
1060 if (status)
1061 return NULL;
1062
1063 gk20a_dbg_info(" Done");
1064
1065 return (struct clk_domain *)board_obj_ptr;
1066}
1067
1068static u32 clk_domain_pmudatainit_super(struct gk20a *g,
1069 struct boardobj *board_obj_ptr,
1070 struct nv_pmu_boardobj *ppmudata)
1071{
1072 u32 status = 0;
1073 struct clk_domain *pclk_domain;
1074 struct nv_pmu_clk_clk_domain_boardobj_set *pset;
1075
1076 gk20a_dbg_info("");
1077
1078 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
1079 if (status != 0)
1080 return status;
1081
1082 pclk_domain = (struct clk_domain *)board_obj_ptr;
1083
1084 pset = (struct nv_pmu_clk_clk_domain_boardobj_set *)ppmudata;
1085
1086 pset->domain = pclk_domain->domain;
1087 pset->api_domain = pclk_domain->api_domain;
1088 pset->perf_domain_grp_idx = pclk_domain->perf_domain_grp_idx;
1089
1090 return status;
1091}
1092
1093u32 clk_domain_clk_prog_link(struct gk20a *g, struct clk_pmupstate *pclk)
1094{
1095 u32 status = 0;
1096 struct clk_domain *pdomain;
1097 u8 i;
1098
1099 /* Iterate over all CLK_DOMAINs and flatten their VF curves.*/
1100 BOARDOBJGRP_FOR_EACH(&(pclk->clk_domainobjs.super.super),
1101 struct clk_domain *, pdomain, i) {
1102 status = pdomain->clkdomainclkproglink(g, pclk, pdomain);
1103 if (status) {
1104 gk20a_err(dev_from_gk20a(g),
1105 "error flattening VF for CLK DOMAIN - 0x%x",
1106 pdomain->domain);
1107 goto done;
1108 }
1109 }
1110
1111done:
1112 return status;
1113}
diff --git a/drivers/gpu/nvgpu/clk/clk_domain.h b/drivers/gpu/nvgpu/clk/clk_domain.h
new file mode 100644
index 00000000..443e1c4c
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_domain.h
@@ -0,0 +1,116 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _CLKDOMAIN_H_
15#define _CLKDOMAIN_H_
16
17#include "ctrl/ctrlclk.h"
18#include "ctrl/ctrlboardobj.h"
19#include "pmuif/gpmuifclk.h"
20#include "boardobj/boardobjgrp_e32.h"
21#include "boardobj/boardobjgrpmask.h"
22
23struct clk_domains;
24struct clk_domain;
25
26/*data and function definition to talk to driver*/
27u32 clk_domain_sw_setup(struct gk20a *g);
28u32 clk_domain_pmu_setup(struct gk20a *g);
29
30typedef u32 clkproglink(struct gk20a *g, struct clk_pmupstate *pclk,
31 struct clk_domain *pdomain);
32
33typedef int clkvfsearch(struct gk20a *g, struct clk_pmupstate *pclk,
34 struct clk_domain *pdomain, u16 *clkmhz,
35 u32 *voltuv, u8 rail);
36
37typedef int clkgetslaveclk(struct gk20a *g, struct clk_pmupstate *pclk,
38 struct clk_domain *pdomain, u16 *clkmhz,
39 u16 masterclkmhz);
40
41typedef u32 clkgetfpoints(struct gk20a *g, struct clk_pmupstate *pclk,
42 struct clk_domain *pdomain, u32 *pfpointscount,
43 u16 *pfreqpointsinmhz, u8 rail);
44
45struct clk_domains {
46 struct boardobjgrp_e32 super;
47 u8 n_num_entries;
48 u8 version;
49 bool b_enforce_vf_monotonicity;
50 bool b_enforce_vf_smoothening;
51 u32 vbios_domains;
52 struct boardobjgrpmask_e32 prog_domains_mask;
53 struct boardobjgrpmask_e32 master_domains_mask;
54 u16 cntr_sampling_periodms;
55 struct ctrl_clk_clk_delta deltas;
56
57 struct clk_domain *ordered_noise_aware_list[CTRL_BOARDOBJ_MAX_BOARD_OBJECTS];
58
59 struct clk_domain *ordered_noise_unaware_list[CTRL_BOARDOBJ_MAX_BOARD_OBJECTS];
60};
61
62struct clk_domain {
63 struct boardobj super;
64 u32 api_domain;
65 u32 part_mask;
66 u8 domain;
67 u8 perf_domain_index;
68 u8 perf_domain_grp_idx;
69 u8 ratio_domain;
70 u8 usage;
71 clkproglink *clkdomainclkproglink;
72 clkvfsearch *clkdomainclkvfsearch;
73 clkgetfpoints *clkdomainclkgetfpoints;
74};
75
76struct clk_domain_3x {
77 struct clk_domain super;
78 bool b_noise_aware_capable;
79};
80
81struct clk_domain_3x_fixed {
82 struct clk_domain_3x super;
83 u16 freq_mhz;
84};
85
86struct clk_domain_3x_prog {
87 struct clk_domain_3x super;
88 u8 clk_prog_idx_first;
89 u8 clk_prog_idx_last;
90 u8 noise_unaware_ordering_index;
91 u8 noise_aware_ordering_index;
92 bool b_force_noise_unaware_ordering;
93 int factory_offset_khz;
94 short freq_delta_min_mhz;
95 short freq_delta_max_mhz;
96 struct ctrl_clk_clk_delta deltas;
97};
98
99struct clk_domain_3x_master {
100 struct clk_domain_3x_prog super;
101 u32 slave_idxs_mask;
102};
103
104struct clk_domain_3x_slave {
105 struct clk_domain_3x_prog super;
106 u8 master_idx;
107 clkgetslaveclk *clkdomainclkgetslaveclk;
108};
109
110u32 clk_domain_clk_prog_link(struct gk20a *g, struct clk_pmupstate *pclk);
111
112#define CLK_CLK_DOMAIN_GET(pclk, idx) \
113 ((struct clk_domain *)BOARDOBJGRP_OBJ_GET_BY_IDX( \
114 &pclk->clk_domainobjs.super.super, (u8)(idx)))
115
116#endif
diff --git a/drivers/gpu/nvgpu/clk/clk_fll.c b/drivers/gpu/nvgpu/clk/clk_fll.c
new file mode 100644
index 00000000..0de857f5
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_fll.c
@@ -0,0 +1,440 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "clk.h"
16#include "clk_fll.h"
17#include "include/bios.h"
18#include "boardobj/boardobjgrp.h"
19#include "boardobj/boardobjgrp_e32.h"
20#include "pmuif/gpmuifboardobj.h"
21#include "pmuif/gpmuifclk.h"
22#include "gm206/bios_gm206.h"
23#include "ctrl/ctrlclk.h"
24#include "ctrl/ctrlvolt.h"
25#include "gk20a/pmu_gk20a.h"
26
27static u32 devinit_get_fll_device_table(struct gk20a *g,
28 struct avfsfllobjs *pfllobjs);
29static struct fll_device *construct_fll_device(struct gk20a *g,
30 void *pargs);
31static u32 fll_device_init_pmudata_super(struct gk20a *g,
32 struct boardobj *board_obj_ptr,
33 struct nv_pmu_boardobj *ppmudata);
34
35static u32 _clk_fll_devgrp_pmudatainit_super(struct gk20a *g,
36 struct boardobjgrp *pboardobjgrp,
37 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu)
38{
39 struct nv_pmu_clk_clk_fll_device_boardobjgrp_set_header *pset =
40 (struct nv_pmu_clk_clk_fll_device_boardobjgrp_set_header *)
41 pboardobjgrppmu;
42 struct avfsfllobjs *pfll_objs = (struct avfsfllobjs *)
43 pboardobjgrp;
44 u32 status = 0;
45
46 gk20a_dbg_info("");
47
48 status = boardobjgrp_pmudatainit_e32(g, pboardobjgrp, pboardobjgrppmu);
49 if (status) {
50 gk20a_err(dev_from_gk20a(g), "failed to init fll pmuobjgrp");
51 return status;
52 }
53 pset->lut_num_entries = pfll_objs->lut_num_entries;
54 pset->lut_step_size_uv = pfll_objs->lut_step_size_uv;
55 pset->lut_min_voltage_uv = pfll_objs->lut_min_voltage_uv;
56 pset->max_min_freq_mhz = pfll_objs->max_min_freq_mhz;
57
58 status = boardobjgrpmask_export(
59 &pfll_objs->lut_prog_master_mask.super,
60 pfll_objs->lut_prog_master_mask.super.bitcount,
61 &pset->lut_prog_master_mask.super);
62
63 gk20a_dbg_info(" Done");
64 return status;
65}
66
67static u32 _clk_fll_devgrp_pmudata_instget(struct gk20a *g,
68 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
69 struct nv_pmu_boardobj **ppboardobjpmudata,
70 u8 idx)
71{
72 struct nv_pmu_clk_clk_fll_device_boardobj_grp_set *pgrp_set =
73 (struct nv_pmu_clk_clk_fll_device_boardobj_grp_set *)
74 pmuboardobjgrp;
75
76 gk20a_dbg_info("");
77
78 /*check whether pmuboardobjgrp has a valid boardobj in index*/
79 if (((u32)BIT(idx) &
80 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
81 return -EINVAL;
82
83 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
84 &pgrp_set->objects[idx].data.board_obj;
85 gk20a_dbg_info(" Done");
86 return 0;
87}
88
89static u32 _clk_fll_devgrp_pmustatus_instget(struct gk20a *g,
90 void *pboardobjgrppmu,
91 struct nv_pmu_boardobj_query **ppboardobjpmustatus,
92 u8 idx)
93{
94 struct nv_pmu_clk_clk_fll_device_boardobj_grp_get_status *pgrp_get_status =
95 (struct nv_pmu_clk_clk_fll_device_boardobj_grp_get_status *)
96 pboardobjgrppmu;
97
98 /*check whether pmuboardobjgrp has a valid boardobj in index*/
99 if (((u32)BIT(idx) &
100 pgrp_get_status->hdr.data.super.obj_mask.super.data[0]) == 0)
101 return -EINVAL;
102
103 *ppboardobjpmustatus = (struct nv_pmu_boardobj_query *)
104 &pgrp_get_status->objects[idx].data.board_obj;
105 return 0;
106}
107
108u32 clk_fll_sw_setup(struct gk20a *g)
109{
110 u32 status;
111 struct boardobjgrp *pboardobjgrp = NULL;
112 struct avfsfllobjs *pfllobjs;
113 struct fll_device *pfll;
114 struct fll_device *pfll_master;
115 struct fll_device *pfll_local;
116 u8 i;
117 u8 j;
118
119 gk20a_dbg_info("");
120
121 status = boardobjgrpconstruct_e32(&g->clk_pmu.avfs_fllobjs.super);
122 if (status) {
123 gk20a_err(dev_from_gk20a(g),
124 "error creating boardobjgrp for fll, status - 0x%x", status);
125 goto done;
126 }
127 pfllobjs = &(g->clk_pmu.avfs_fllobjs);
128 pboardobjgrp = &(g->clk_pmu.avfs_fllobjs.super.super);
129
130 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, CLK, FLL_DEVICE);
131
132 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
133 clk, CLK, clk_fll_device, CLK_FLL_DEVICE);
134 if (status) {
135 gk20a_err(dev_from_gk20a(g),
136 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
137 status);
138 goto done;
139 }
140
141 pboardobjgrp->pmudatainit = _clk_fll_devgrp_pmudatainit_super;
142 pboardobjgrp->pmudatainstget = _clk_fll_devgrp_pmudata_instget;
143 pboardobjgrp->pmustatusinstget = _clk_fll_devgrp_pmustatus_instget;
144 pfllobjs = (struct avfsfllobjs *)pboardobjgrp;
145 pfllobjs->lut_num_entries = CTRL_CLK_LUT_NUM_ENTRIES;
146 pfllobjs->lut_step_size_uv = CTRL_CLK_VIN_STEP_SIZE_UV;
147 pfllobjs->lut_min_voltage_uv = CTRL_CLK_LUT_MIN_VOLTAGE_UV;
148
149 /* Initialize lut prog master mask to zero.*/
150 boardobjgrpmask_e32_init(&pfllobjs->lut_prog_master_mask, NULL);
151
152 status = devinit_get_fll_device_table(g, pfllobjs);
153 if (status)
154 goto done;
155
156 status = BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g,
157 &g->clk_pmu.avfs_fllobjs.super.super,
158 clk, CLK, clk_fll_device, CLK_FLL_DEVICE);
159 if (status) {
160 gk20a_err(dev_from_gk20a(g),
161 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
162 status);
163 goto done;
164 }
165
166 BOARDOBJGRP_FOR_EACH(&(pfllobjs->super.super),
167 struct fll_device *, pfll, i) {
168 pfll_master = NULL;
169 j = 0;
170 BOARDOBJGRP_ITERATOR(&(pfllobjs->super.super),
171 struct fll_device *, pfll_local, j,
172 &pfllobjs->lut_prog_master_mask.super) {
173 if (pfll_local->clk_domain == pfll->clk_domain) {
174 pfll_master = pfll_local;
175 break;
176 }
177 }
178
179 if (pfll_master == NULL) {
180 status = boardobjgrpmask_bitset(
181 &pfllobjs->lut_prog_master_mask.super,
182 BOARDOBJ_GET_IDX(pfll));
183 if (status) {
184 gk20a_err(dev_from_gk20a(g), "err setting lutprogmask");
185 goto done;
186 }
187 pfll_master = pfll;
188 }
189 status = pfll_master->lut_broadcast_slave_register(
190 g, pfllobjs, pfll_master, pfll);
191
192 if (status) {
193 gk20a_err(dev_from_gk20a(g), "err setting lutslavemask");
194 goto done;
195 }
196 }
197done:
198 gk20a_dbg_info(" done status %x", status);
199 return status;
200}
201
202u32 clk_fll_pmu_setup(struct gk20a *g)
203{
204 u32 status;
205 struct boardobjgrp *pboardobjgrp = NULL;
206
207 gk20a_dbg_info("");
208
209 pboardobjgrp = &g->clk_pmu.avfs_fllobjs.super.super;
210
211 if (!pboardobjgrp->bconstructed)
212 return -EINVAL;
213
214 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
215
216 gk20a_dbg_info("Done");
217 return status;
218}
219
220static u32 devinit_get_fll_device_table(struct gk20a *g,
221 struct avfsfllobjs *pfllobjs)
222{
223 u32 status = 0;
224 u8 *fll_table_ptr = NULL;
225 struct fll_descriptor_header fll_desc_table_header_sz = { 0 };
226 struct fll_descriptor_header_10 fll_desc_table_header = { 0 };
227 struct fll_descriptor_entry_10 fll_desc_table_entry = { 0 };
228 u8 *fll_tbl_entry_ptr = NULL;
229 u32 index = 0;
230 struct fll_device fll_dev_data;
231 struct fll_device *pfll_dev;
232 struct vin_device *pvin_dev;
233 u32 desctablesize;
234 u32 vbios_domain = NV_PERF_DOMAIN_4X_CLOCK_DOMAIN_SKIP;
235 struct avfsvinobjs *pvinobjs = &g->clk_pmu.avfs_vinobjs;
236
237 gk20a_dbg_info("");
238
239 if (g->ops.bios.get_perf_table_ptrs) {
240 fll_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
241 g->bios.clock_token, FLL_TABLE);
242 if (fll_table_ptr == NULL) {
243 status = -1;
244 goto done;
245 }
246 }
247
248 memcpy(&fll_desc_table_header_sz, fll_table_ptr,
249 sizeof(struct fll_descriptor_header));
250 if (fll_desc_table_header_sz.size >= FLL_DESCRIPTOR_HEADER_10_SIZE_6)
251 desctablesize = FLL_DESCRIPTOR_HEADER_10_SIZE_6;
252 else
253 desctablesize = FLL_DESCRIPTOR_HEADER_10_SIZE_4;
254
255 memcpy(&fll_desc_table_header, fll_table_ptr, desctablesize);
256
257 if (desctablesize == FLL_DESCRIPTOR_HEADER_10_SIZE_6)
258 pfllobjs->max_min_freq_mhz =
259 fll_desc_table_header.max_min_freq_mhz;
260 else
261 pfllobjs->max_min_freq_mhz = 0;
262
263 /* Read table entries*/
264 fll_tbl_entry_ptr = fll_table_ptr + desctablesize;
265 for (index = 0; index < fll_desc_table_header.entry_count; index++) {
266 u32 fll_id;
267
268 memcpy(&fll_desc_table_entry, fll_tbl_entry_ptr,
269 sizeof(struct fll_descriptor_entry_10));
270
271 if (fll_desc_table_entry.fll_device_type == CTRL_CLK_FLL_TYPE_DISABLED)
272 continue;
273
274 fll_id = fll_desc_table_entry.fll_device_id;
275
276 pvin_dev = CLK_GET_VIN_DEVICE(pvinobjs,
277 (u8)fll_desc_table_entry.vin_idx_logic);
278 if (pvin_dev == NULL)
279 return -EINVAL;
280
281 pvin_dev->flls_shared_mask |= BIT(fll_id);
282
283 pvin_dev = CLK_GET_VIN_DEVICE(pvinobjs,
284 (u8)fll_desc_table_entry.vin_idx_sram);
285 if (pvin_dev == NULL)
286 return -EINVAL;
287
288 pvin_dev->flls_shared_mask |= BIT(fll_id);
289
290 fll_dev_data.super.type =
291 (u8)fll_desc_table_entry.fll_device_type;
292 fll_dev_data.id = (u8)fll_desc_table_entry.fll_device_id;
293 fll_dev_data.mdiv = (u8)BIOS_GET_FIELD(
294 fll_desc_table_entry.fll_params,
295 NV_FLL_DESC_FLL_PARAMS_MDIV);
296 fll_dev_data.input_freq_mhz =
297 (u16)fll_desc_table_entry.ref_freq_mhz;
298 fll_dev_data.min_freq_vfe_idx =
299 (u8)fll_desc_table_entry.min_freq_vfe_idx;
300 fll_dev_data.freq_ctrl_idx = CTRL_BOARDOBJ_IDX_INVALID;
301
302 vbios_domain = (u32)(fll_desc_table_entry.clk_domain &
303 NV_PERF_DOMAIN_4X_CLOCK_DOMAIN_MASK);
304 if (vbios_domain == 0)
305 fll_dev_data.clk_domain = CTRL_CLK_DOMAIN_GPC2CLK;
306 else if (vbios_domain == 1)
307 fll_dev_data.clk_domain = CTRL_CLK_DOMAIN_XBAR2CLK;
308 else if (vbios_domain == 3)
309 fll_dev_data.clk_domain = CTRL_CLK_DOMAIN_SYS2CLK;
310 else
311 continue;
312
313 fll_dev_data.rail_idx_for_lut = 0;
314
315 fll_dev_data.vin_idx_logic =
316 (u8)fll_desc_table_entry.vin_idx_logic;
317 fll_dev_data.vin_idx_sram =
318 (u8)fll_desc_table_entry.vin_idx_sram;
319 fll_dev_data.lut_device.vselect_mode =
320 (u8)BIOS_GET_FIELD(fll_desc_table_entry.lut_params,
321 NV_FLL_DESC_LUT_PARAMS_VSELECT);
322 fll_dev_data.lut_device.hysteresis_threshold =
323 (u8)BIOS_GET_FIELD(fll_desc_table_entry.lut_params,
324 NV_FLL_DESC_LUT_PARAMS_HYSTERISIS_THRESHOLD);
325 fll_dev_data.regime_desc.regime_id =
326 CTRL_CLK_FLL_REGIME_ID_FFR;
327 fll_dev_data.regime_desc.fixed_freq_regime_limit_mhz =
328 (u16)fll_desc_table_entry.ffr_cutoff_freq_mhz;
329
330 /*construct fll device*/
331 pfll_dev = construct_fll_device(g, (void *)&fll_dev_data);
332
333 status = boardobjgrp_objinsert(&pfllobjs->super.super,
334 (struct boardobj *)pfll_dev, index);
335
336 fll_tbl_entry_ptr += fll_desc_table_header.entry_size;
337 }
338
339done:
340 gk20a_dbg_info(" done status %x", status);
341 return status;
342}
343
344static u32 lutbroadcastslaveregister(struct gk20a *g,
345 struct avfsfllobjs *pfllobjs,
346 struct fll_device *pfll,
347 struct fll_device *pfll_slave)
348{
349 if (pfll->clk_domain != pfll_slave->clk_domain)
350 return -EINVAL;
351
352 return boardobjgrpmask_bitset(&pfll->
353 lut_prog_broadcast_slave_mask.super,
354 BOARDOBJ_GET_IDX(pfll_slave));
355}
356
357static struct fll_device *construct_fll_device(struct gk20a *g,
358 void *pargs)
359{
360 struct boardobj *board_obj_ptr = NULL;
361 struct fll_device *pfll_dev;
362 struct fll_device *board_obj_fll_ptr = NULL;
363 u32 status;
364
365 gk20a_dbg_info("");
366 status = boardobj_construct_super(g, &board_obj_ptr,
367 sizeof(struct fll_device), pargs);
368 if (status)
369 return NULL;
370
371 pfll_dev = (struct fll_device *)pargs;
372 board_obj_fll_ptr = (struct fll_device *)board_obj_ptr;
373 board_obj_ptr->pmudatainit = fll_device_init_pmudata_super;
374 board_obj_fll_ptr->lut_broadcast_slave_register =
375 lutbroadcastslaveregister;
376 board_obj_fll_ptr->id = pfll_dev->id;
377 board_obj_fll_ptr->mdiv = pfll_dev->mdiv;
378 board_obj_fll_ptr->rail_idx_for_lut = pfll_dev->rail_idx_for_lut;
379 board_obj_fll_ptr->input_freq_mhz = pfll_dev->input_freq_mhz;
380 board_obj_fll_ptr->clk_domain = pfll_dev->clk_domain;
381 board_obj_fll_ptr->vin_idx_logic = pfll_dev->vin_idx_logic;
382 board_obj_fll_ptr->vin_idx_sram = pfll_dev->vin_idx_sram;
383 board_obj_fll_ptr->min_freq_vfe_idx =
384 pfll_dev->min_freq_vfe_idx;
385 board_obj_fll_ptr->freq_ctrl_idx = pfll_dev->freq_ctrl_idx;
386 memcpy(&board_obj_fll_ptr->lut_device, &pfll_dev->lut_device,
387 sizeof(struct nv_pmu_clk_lut_device_desc));
388 memcpy(&board_obj_fll_ptr->regime_desc, &pfll_dev->regime_desc,
389 sizeof(struct nv_pmu_clk_regime_desc));
390 boardobjgrpmask_e32_init(
391 &board_obj_fll_ptr->lut_prog_broadcast_slave_mask, NULL);
392
393 gk20a_dbg_info(" Done");
394
395 return (struct fll_device *)board_obj_ptr;
396}
397
398static u32 fll_device_init_pmudata_super(struct gk20a *g,
399 struct boardobj *board_obj_ptr,
400 struct nv_pmu_boardobj *ppmudata)
401{
402 u32 status = 0;
403 struct fll_device *pfll_dev;
404 struct nv_pmu_clk_clk_fll_device_boardobj_set *perf_pmu_data;
405
406 gk20a_dbg_info("");
407
408 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
409 if (status != 0)
410 return status;
411
412 pfll_dev = (struct fll_device *)board_obj_ptr;
413 perf_pmu_data = (struct nv_pmu_clk_clk_fll_device_boardobj_set *)
414 ppmudata;
415
416 perf_pmu_data->id = pfll_dev->id;
417 perf_pmu_data->mdiv = pfll_dev->mdiv;
418 perf_pmu_data->rail_idx_for_lut = pfll_dev->rail_idx_for_lut;
419 perf_pmu_data->input_freq_mhz = pfll_dev->input_freq_mhz;
420 perf_pmu_data->vin_idx_logic = pfll_dev->vin_idx_logic;
421 perf_pmu_data->vin_idx_sram = pfll_dev->vin_idx_sram;
422 perf_pmu_data->clk_domain = pfll_dev->clk_domain;
423 perf_pmu_data->min_freq_vfe_idx =
424 pfll_dev->min_freq_vfe_idx;
425 perf_pmu_data->freq_ctrl_idx = pfll_dev->freq_ctrl_idx;
426
427 memcpy(&perf_pmu_data->lut_device, &pfll_dev->lut_device,
428 sizeof(struct nv_pmu_clk_lut_device_desc));
429 memcpy(&perf_pmu_data->regime_desc, &pfll_dev->regime_desc,
430 sizeof(struct nv_pmu_clk_regime_desc));
431
432 status = boardobjgrpmask_export(
433 &pfll_dev->lut_prog_broadcast_slave_mask.super,
434 pfll_dev->lut_prog_broadcast_slave_mask.super.bitcount,
435 &perf_pmu_data->lut_prog_broadcast_slave_mask.super);
436
437 gk20a_dbg_info(" Done");
438
439 return status;
440}
diff --git a/drivers/gpu/nvgpu/clk/clk_fll.h b/drivers/gpu/nvgpu/clk/clk_fll.h
new file mode 100644
index 00000000..06872f48
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_fll.h
@@ -0,0 +1,68 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _CLKFLL_H_
15#define _CLKFLL_H_
16
17#include "pmuif/gpmuifclk.h"
18#include "boardobj/boardobjgrp_e32.h"
19#include "boardobj/boardobjgrpmask.h"
20
21/*data and function definition to talk to driver*/
22u32 clk_fll_sw_setup(struct gk20a *g);
23u32 clk_fll_pmu_setup(struct gk20a *g);
24
25struct avfsfllobjs {
26 struct boardobjgrp_e32 super;
27 struct boardobjgrpmask_e32 lut_prog_master_mask;
28 u32 lut_step_size_uv;
29 u32 lut_min_voltage_uv;
30 u8 lut_num_entries;
31 u16 max_min_freq_mhz;
32};
33
34struct fll_device;
35
36typedef u32 fll_lut_broadcast_slave_register(struct gk20a *g,
37 struct avfsfllobjs *pfllobjs,
38 struct fll_device *pfll,
39 struct fll_device *pfll_slave);
40
41struct fll_device {
42 struct boardobj super;
43 u8 id;
44 u8 mdiv;
45 u16 input_freq_mhz;
46 u32 clk_domain;
47 u8 vin_idx_logic;
48 u8 vin_idx_sram;
49 u8 rail_idx_for_lut;
50 struct nv_pmu_clk_lut_device_desc lut_device;
51 struct nv_pmu_clk_regime_desc regime_desc;
52 u8 min_freq_vfe_idx;
53 u8 freq_ctrl_idx;
54 u8 target_regime_id_override;
55 struct boardobjgrpmask_e32 lut_prog_broadcast_slave_mask;
56 fll_lut_broadcast_slave_register *lut_broadcast_slave_register;
57};
58
59#define CLK_FLL_LUT_VF_NUM_ENTRIES(pclk) \
60 (pclk->avfs_fllobjs.lut_num_entries)
61
62#define CLK_FLL_LUT_MIN_VOLTAGE_UV(pclk) \
63 (pclk->avfs_fllobjs.lut_min_voltage_uv)
64#define CLK_FLL_LUT_STEP_SIZE_UV(pclk) \
65 (pclk->avfs_fllobjs.lut_step_size_uv)
66
67#endif
68
diff --git a/drivers/gpu/nvgpu/clk/clk_freq_controller.c b/drivers/gpu/nvgpu/clk/clk_freq_controller.c
new file mode 100644
index 00000000..17f79168
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_freq_controller.c
@@ -0,0 +1,454 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "clk.h"
16#include "clk_fll.h"
17#include "clk_domain.h"
18#include "clk_freq_controller.h"
19#include "include/bios.h"
20#include "boardobj/boardobjgrp.h"
21#include "boardobj/boardobjgrp_e32.h"
22#include "pmuif/gpmuifboardobj.h"
23#include "pmuif/gpmuifclk.h"
24#include "gm206/bios_gm206.h"
25#include "ctrl/ctrlclk.h"
26#include "ctrl/ctrlvolt.h"
27#include "gk20a/pmu_gk20a.h"
28
29static u32 clk_freq_controller_pmudatainit_super(struct gk20a *g,
30 struct boardobj *board_obj_ptr,
31 struct nv_pmu_boardobj *ppmudata)
32{
33 struct nv_pmu_clk_clk_freq_controller_boardobj_set *pfreq_cntlr_set;
34 struct clk_freq_controller *pfreq_cntlr;
35 u32 status = 0;
36
37 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
38 if (status)
39 return status;
40
41 pfreq_cntlr_set =
42 (struct nv_pmu_clk_clk_freq_controller_boardobj_set *)ppmudata;
43 pfreq_cntlr = (struct clk_freq_controller *)board_obj_ptr;
44
45 pfreq_cntlr_set->controller_id = pfreq_cntlr->controller_id;
46 pfreq_cntlr_set->clk_domain = pfreq_cntlr->clk_domain;
47 pfreq_cntlr_set->parts_freq_mode = pfreq_cntlr->parts_freq_mode;
48 pfreq_cntlr_set->bdisable = pfreq_cntlr->bdisable;
49 pfreq_cntlr_set->freq_cap_noise_unaware_vmin_above =
50 pfreq_cntlr->freq_cap_noise_unaware_vmin_above;
51 pfreq_cntlr_set->freq_cap_noise_unaware_vmin_below =
52 pfreq_cntlr->freq_cap_noise_unaware_vmin_below;
53 pfreq_cntlr_set->freq_hyst_pos_mhz = pfreq_cntlr->freq_hyst_pos_mhz;
54 pfreq_cntlr_set->freq_hyst_neg_mhz = pfreq_cntlr->freq_hyst_neg_mhz;
55
56 return status;
57}
58
59static u32 clk_freq_controller_pmudatainit_pi(struct gk20a *g,
60 struct boardobj *board_obj_ptr,
61 struct nv_pmu_boardobj *ppmudata)
62{
63 struct nv_pmu_clk_clk_freq_controller_pi_boardobj_set
64 *pfreq_cntlr_pi_set;
65 struct clk_freq_controller_pi *pfreq_cntlr_pi;
66 u32 status = 0;
67
68 status = clk_freq_controller_pmudatainit_super(g,
69 board_obj_ptr, ppmudata);
70 if (status)
71 return -1;
72
73 pfreq_cntlr_pi_set =
74 (struct nv_pmu_clk_clk_freq_controller_pi_boardobj_set *)
75 ppmudata;
76 pfreq_cntlr_pi = (struct clk_freq_controller_pi *)board_obj_ptr;
77
78 pfreq_cntlr_pi_set->prop_gain = pfreq_cntlr_pi->prop_gain;
79 pfreq_cntlr_pi_set->integ_gain = pfreq_cntlr_pi->integ_gain;
80 pfreq_cntlr_pi_set->integ_decay = pfreq_cntlr_pi->integ_decay;
81 pfreq_cntlr_pi_set->volt_delta_min = pfreq_cntlr_pi->volt_delta_min;
82 pfreq_cntlr_pi_set->volt_delta_max = pfreq_cntlr_pi->volt_delta_max;
83 pfreq_cntlr_pi_set->slowdown_pct_min = pfreq_cntlr_pi->slowdown_pct_min;
84 pfreq_cntlr_pi_set->bpoison = pfreq_cntlr_pi->bpoison;
85
86 return status;
87}
88
89static u32 clk_freq_controller_construct_super(struct gk20a *g,
90 struct boardobj **ppboardobj,
91 u16 size, void *pargs)
92{
93 struct clk_freq_controller *pfreq_cntlr = NULL;
94 struct clk_freq_controller *pfreq_cntlr_tmp = NULL;
95 u32 status = 0;
96
97 status = boardobj_construct_super(g, ppboardobj, size, pargs);
98 if (status)
99 return -EINVAL;
100
101 pfreq_cntlr_tmp = (struct clk_freq_controller *)pargs;
102 pfreq_cntlr = (struct clk_freq_controller *)*ppboardobj;
103
104 pfreq_cntlr->super.pmudatainit = clk_freq_controller_pmudatainit_super;
105
106 pfreq_cntlr->controller_id = pfreq_cntlr_tmp->controller_id;
107 pfreq_cntlr->clk_domain = pfreq_cntlr_tmp->clk_domain;
108 pfreq_cntlr->parts_freq_mode = pfreq_cntlr_tmp->parts_freq_mode;
109 pfreq_cntlr->freq_cap_noise_unaware_vmin_above =
110 pfreq_cntlr_tmp->freq_cap_noise_unaware_vmin_above;
111 pfreq_cntlr->freq_cap_noise_unaware_vmin_below =
112 pfreq_cntlr_tmp->freq_cap_noise_unaware_vmin_below;
113 pfreq_cntlr->freq_hyst_pos_mhz = pfreq_cntlr_tmp->freq_hyst_pos_mhz;
114 pfreq_cntlr->freq_hyst_neg_mhz = pfreq_cntlr_tmp->freq_hyst_neg_mhz;
115
116 return status;
117}
118
119static u32 clk_freq_controller_construct_pi(struct gk20a *g,
120 struct boardobj **ppboardobj,
121 u16 size, void *pargs)
122{
123 struct clk_freq_controller_pi *pfreq_cntlr_pi = NULL;
124 struct clk_freq_controller_pi *pfreq_cntlr_pi_tmp = NULL;
125 u32 status = 0;
126
127 status = clk_freq_controller_construct_super(g, ppboardobj,
128 size, pargs);
129 if (status)
130 return -EINVAL;
131
132 pfreq_cntlr_pi = (struct clk_freq_controller_pi *)*ppboardobj;
133 pfreq_cntlr_pi_tmp = (struct clk_freq_controller_pi *)pargs;
134
135 pfreq_cntlr_pi->super.super.pmudatainit =
136 clk_freq_controller_pmudatainit_pi;
137
138 pfreq_cntlr_pi->prop_gain = pfreq_cntlr_pi_tmp->prop_gain;
139 pfreq_cntlr_pi->integ_gain = pfreq_cntlr_pi_tmp->integ_gain;
140 pfreq_cntlr_pi->integ_decay = pfreq_cntlr_pi_tmp->integ_decay;
141 pfreq_cntlr_pi->volt_delta_min = pfreq_cntlr_pi_tmp->volt_delta_min;
142 pfreq_cntlr_pi->volt_delta_max = pfreq_cntlr_pi_tmp->volt_delta_max;
143 pfreq_cntlr_pi->slowdown_pct_min = pfreq_cntlr_pi_tmp->slowdown_pct_min;
144 pfreq_cntlr_pi->bpoison = pfreq_cntlr_pi_tmp->bpoison;
145
146 return status;
147}
148
149struct clk_freq_controller *clk_clk_freq_controller_construct(struct gk20a *g,
150 void *pargs)
151{
152 struct boardobj *board_obj_ptr = NULL;
153 u32 status = 0;
154
155 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_FREQ_CONTROLLER_TYPE_PI)
156 return NULL;
157
158 status = clk_freq_controller_construct_pi(g, &board_obj_ptr,
159 sizeof(struct clk_freq_controller_pi), pargs);
160 if (status)
161 return NULL;
162
163 return (struct clk_freq_controller *)board_obj_ptr;
164}
165
166
167static u32 clk_get_freq_controller_table(struct gk20a *g,
168 struct clk_freq_controllers *pclk_freq_controllers)
169{
170 u32 status = 0;
171 u8 *pfreq_controller_table_ptr = NULL;
172 struct vbios_fct_1x_header header = { 0 };
173 struct vbios_fct_1x_entry entry = { 0 };
174 u8 entry_idx;
175 u8 *entry_offset;
176 u32 freq_controller_id;
177 struct clk_freq_controller *pclk_freq_cntr = NULL;
178 struct clk_freq_controller *ptmp_freq_cntr = NULL;
179 struct clk_freq_controller_pi *ptmp_freq_cntr_pi = NULL;
180 struct clk_domain *pclk_domain;
181
182 struct freq_controller_data_type {
183 union {
184 struct boardobj board_obj;
185 struct clk_freq_controller freq_controller;
186 struct clk_freq_controller_pi freq_controller_pi;
187 };
188 } freq_controller_data;
189
190 if (g->ops.bios.get_perf_table_ptrs) {
191 pfreq_controller_table_ptr =
192 (u8 *)g->ops.bios.get_perf_table_ptrs(g,
193 g->bios.clock_token,
194 FREQUENCY_CONTROLLER_TABLE);
195 if (pfreq_controller_table_ptr == NULL) {
196 status = -EINVAL;
197 goto done;
198 }
199 } else {
200 status = -EINVAL;
201 goto done;
202 }
203
204 memcpy(&header, pfreq_controller_table_ptr,
205 sizeof(struct vbios_fct_1x_header));
206
207 pclk_freq_controllers->sampling_period_ms = header.sampling_period_ms;
208 pclk_freq_controllers->volt_policy_idx = 0;
209
210 /* Read in the entries. */
211 for (entry_idx = 0; entry_idx < header.entry_count; entry_idx++) {
212 entry_offset = (pfreq_controller_table_ptr +
213 header.header_size + (entry_idx * header.entry_size));
214
215 memset(&freq_controller_data, 0x0,
216 sizeof(struct freq_controller_data_type));
217 ptmp_freq_cntr = &freq_controller_data.freq_controller;
218 ptmp_freq_cntr_pi = &freq_controller_data.freq_controller_pi;
219
220 memcpy(&entry, entry_offset,
221 sizeof(struct vbios_fct_1x_entry));
222
223 if (!BIOS_GET_FIELD(entry.flags0,
224 NV_VBIOS_FCT_1X_ENTRY_FLAGS0_TYPE))
225 continue;
226
227 freq_controller_data.board_obj.type = (u8)BIOS_GET_FIELD(
228 entry.flags0, NV_VBIOS_FCT_1X_ENTRY_FLAGS0_TYPE);
229
230 ptmp_freq_cntr->controller_id =
231 (u8)BIOS_GET_FIELD(entry.param0,
232 NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID);
233
234 freq_controller_id = ptmp_freq_cntr->controller_id;
235
236 pclk_domain = CLK_CLK_DOMAIN_GET((&g->clk_pmu),
237 (u32)entry.clk_domain_idx);
238 freq_controller_data.freq_controller.clk_domain =
239 pclk_domain->api_domain;
240
241 ptmp_freq_cntr->parts_freq_mode =
242 (u8)BIOS_GET_FIELD(entry.param0,
243 NV_VBIOS_FCT_1X_ENTRY_PARAM0_FREQ_MODE);
244
245 /* Populate PI specific data */
246 ptmp_freq_cntr_pi->slowdown_pct_min =
247 (u8)BIOS_GET_FIELD(entry.param1,
248 NV_VBIOS_FCT_1X_ENTRY_PARAM1_SLOWDOWN_PCT_MIN);
249
250 ptmp_freq_cntr_pi->bpoison =
251 BIOS_GET_FIELD(entry.param1,
252 NV_VBIOS_FCT_1X_ENTRY_PARAM1_POISON);
253
254 ptmp_freq_cntr_pi->prop_gain =
255 (s32)BIOS_GET_FIELD(entry.param2,
256 NV_VBIOS_FCT_1X_ENTRY_PARAM2_PROP_GAIN);
257
258 ptmp_freq_cntr_pi->integ_gain =
259 (s32)BIOS_GET_FIELD(entry.param3,
260 NV_VBIOS_FCT_1X_ENTRY_PARAM3_INTEG_GAIN);
261
262 ptmp_freq_cntr_pi->integ_decay =
263 (s32)BIOS_GET_FIELD(entry.param4,
264 NV_VBIOS_FCT_1X_ENTRY_PARAM4_INTEG_DECAY);
265
266 ptmp_freq_cntr_pi->volt_delta_min =
267 (s32)BIOS_GET_FIELD(entry.param5,
268 NV_VBIOS_FCT_1X_ENTRY_PARAM5_VOLT_DELTA_MIN);
269
270 ptmp_freq_cntr_pi->volt_delta_max =
271 (s32)BIOS_GET_FIELD(entry.param6,
272 NV_VBIOS_FCT_1X_ENTRY_PARAM6_VOLT_DELTA_MAX);
273
274 ptmp_freq_cntr->freq_cap_noise_unaware_vmin_above =
275 (s16)BIOS_GET_FIELD(entry.param7,
276 NV_VBIOS_FCT_1X_ENTRY_PARAM7_FREQ_CAP_VF);
277
278 ptmp_freq_cntr->freq_cap_noise_unaware_vmin_below =
279 (s16)BIOS_GET_FIELD(entry.param7,
280 NV_VBIOS_FCT_1X_ENTRY_PARAM7_FREQ_CAP_VMIN);
281
282 ptmp_freq_cntr->freq_hyst_pos_mhz =
283 (s16)BIOS_GET_FIELD(entry.param8,
284 NV_VBIOS_FCT_1X_ENTRY_PARAM8_FREQ_HYST_POS);
285 ptmp_freq_cntr->freq_hyst_neg_mhz =
286 (s16)BIOS_GET_FIELD(entry.param8,
287 NV_VBIOS_FCT_1X_ENTRY_PARAM8_FREQ_HYST_NEG);
288
289 if (ptmp_freq_cntr_pi->volt_delta_max <
290 ptmp_freq_cntr_pi->volt_delta_min)
291 goto done;
292
293 pclk_freq_cntr = clk_clk_freq_controller_construct(g,
294 (void *)&freq_controller_data);
295
296 if (pclk_freq_cntr == NULL) {
297 gk20a_err(dev_from_gk20a(g),
298 "unable to construct clock freq cntlr boardobj for %d",
299 entry_idx);
300 status = -EINVAL;
301 goto done;
302 }
303
304 status = boardobjgrp_objinsert(
305 &pclk_freq_controllers->super.super,
306 (struct boardobj *)pclk_freq_cntr, entry_idx);
307 if (status) {
308 gk20a_err(dev_from_gk20a(g),
309 "unable to insert clock freq cntlr boardobj for");
310 status = -EINVAL;
311 goto done;
312 }
313
314 }
315
316done:
317 return status;
318}
319
320u32 clk_freq_controller_pmu_setup(struct gk20a *g)
321{
322 u32 status;
323 struct boardobjgrp *pboardobjgrp = NULL;
324
325 gk20a_dbg_info("");
326
327 pboardobjgrp = &g->clk_pmu.clk_freq_controllers.super.super;
328
329 if (!pboardobjgrp->bconstructed)
330 return -EINVAL;
331
332 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
333
334 gk20a_dbg_info("Done");
335 return status;
336}
337
338static u32 _clk_freq_controller_devgrp_pmudata_instget(struct gk20a *g,
339 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
340 struct nv_pmu_boardobj **ppboardobjpmudata,
341 u8 idx)
342{
343 struct nv_pmu_clk_clk_freq_controller_boardobj_grp_set *pgrp_set =
344 (struct nv_pmu_clk_clk_freq_controller_boardobj_grp_set *)
345 pmuboardobjgrp;
346
347 gk20a_dbg_info("");
348
349 /*check whether pmuboardobjgrp has a valid boardobj in index*/
350 if (((u32)BIT(idx) &
351 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
352 return -EINVAL;
353
354 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
355 &pgrp_set->objects[idx].data.board_obj;
356 gk20a_dbg_info(" Done");
357 return 0;
358}
359
360static u32 _clk_freq_controllers_pmudatainit(struct gk20a *g,
361 struct boardobjgrp *pboardobjgrp,
362 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu)
363{
364 struct nv_pmu_clk_clk_freq_controller_boardobjgrp_set_header *pset =
365 (struct nv_pmu_clk_clk_freq_controller_boardobjgrp_set_header *)
366 pboardobjgrppmu;
367 struct clk_freq_controllers *pcntrs =
368 (struct clk_freq_controllers *)pboardobjgrp;
369 u32 status = 0;
370
371 status = boardobjgrp_pmudatainit_e32(g, pboardobjgrp, pboardobjgrppmu);
372 if (status) {
373 gk20a_err(dev_from_gk20a(g),
374 "error updating pmu boardobjgrp for clk freq ctrs 0x%x",
375 status);
376 goto done;
377 }
378 pset->sampling_period_ms = pcntrs->sampling_period_ms;
379 pset->volt_policy_idx = pcntrs->volt_policy_idx;
380
381done:
382 return status;
383}
384
385u32 clk_freq_controller_sw_setup(struct gk20a *g)
386{
387 u32 status = 0;
388 struct boardobjgrp *pboardobjgrp = NULL;
389 struct clk_freq_controllers *pclk_freq_controllers;
390 struct avfsfllobjs *pfllobjs = &(g->clk_pmu.avfs_fllobjs);
391 struct fll_device *pfll;
392 struct clk_freq_controller *pclkfreqctrl;
393 u8 i;
394 u8 j;
395
396 gk20a_dbg_info("");
397
398 pclk_freq_controllers = &g->clk_pmu.clk_freq_controllers;
399 status = boardobjgrpconstruct_e32(&pclk_freq_controllers->super);
400 if (status) {
401 gk20a_err(dev_from_gk20a(g),
402 "error creating boardobjgrp for clk FCT, status - 0x%x",
403 status);
404 goto done;
405 }
406
407 pboardobjgrp = &g->clk_pmu.clk_freq_controllers.super.super;
408
409 pboardobjgrp->pmudatainit = _clk_freq_controllers_pmudatainit;
410 pboardobjgrp->pmudatainstget =
411 _clk_freq_controller_devgrp_pmudata_instget;
412 pboardobjgrp->pmustatusinstget = NULL;
413
414 /* Initialize mask to zero.*/
415 boardobjgrpmask_e32_init(&pclk_freq_controllers->freq_ctrl_load_mask,
416 NULL);
417
418 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, CLK, CLK_FREQ_CONTROLLER);
419
420 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
421 clk, CLK, clk_freq_controller, CLK_FREQ_CONTROLLER);
422 if (status) {
423 gk20a_err(dev_from_gk20a(g),
424 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
425 status);
426 goto done;
427 }
428
429 status = clk_get_freq_controller_table(g, pclk_freq_controllers);
430 if (status) {
431 gk20a_err(dev_from_gk20a(g),
432 "error reading freq controller table - 0x%x",
433 status);
434 goto done;
435 }
436
437 BOARDOBJGRP_FOR_EACH(&(pclk_freq_controllers->super.super),
438 struct clk_freq_controller *, pclkfreqctrl, i) {
439 pfll = NULL;
440 j = 0;
441 BOARDOBJGRP_FOR_EACH(&(pfllobjs->super.super),
442 struct fll_device *, pfll, j) {
443 if (pclkfreqctrl->controller_id == pfll->id) {
444 pfll->freq_ctrl_idx = i;
445 break;
446 }
447 }
448 boardobjgrpmask_bitset(&pclk_freq_controllers->
449 freq_ctrl_load_mask.super, i);
450 }
451done:
452 gk20a_dbg_info(" done status %x", status);
453 return status;
454}
diff --git a/drivers/gpu/nvgpu/clk/clk_freq_controller.h b/drivers/gpu/nvgpu/clk/clk_freq_controller.h
new file mode 100644
index 00000000..957a4f08
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_freq_controller.h
@@ -0,0 +1,74 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _CLK_FREQ_CONTROLLER_H_
15#define _CLK_FREQ_CONTROLLER_H_
16
17#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_SYS 0x00
18#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_LTC 0x01
19#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_XBAR 0x02
20#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC0 0x03
21#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC1 0x04
22#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC2 0x05
23#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC3 0x06
24#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC4 0x07
25#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC5 0x08
26#define CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPCS 0x09
27
28#define CTRL_CLK_CLK_FREQ_CONTROLLER_MASK_UNICAST_GPC \
29 (BIT(CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC0) | \
30 BIT(CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC1) | \
31 BIT(CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC2) | \
32 BIT(CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC3) | \
33 BIT(CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC4) | \
34 BIT(CTRL_CLK_CLK_FREQ_CONTROLLER_ID_GPC5))
35
36#define CTRL_CLK_CLK_FREQ_CONTROLLER_TYPE_DISABLED 0x00
37#define CTRL_CLK_CLK_FREQ_CONTROLLER_TYPE_PI 0x01
38
39
40struct clk_freq_controller {
41 struct boardobj super;
42 u8 controller_id;
43 u8 parts_freq_mode;
44 bool bdisable;
45 u32 clk_domain;
46 s16 freq_cap_noise_unaware_vmin_above;
47 s16 freq_cap_noise_unaware_vmin_below;
48 s16 freq_hyst_pos_mhz;
49 s16 freq_hyst_neg_mhz;
50};
51
52struct clk_freq_controller_pi {
53 struct clk_freq_controller super;
54 s32 prop_gain;
55 s32 integ_gain;
56 s32 integ_decay;
57 s32 volt_delta_min;
58 s32 volt_delta_max;
59 u8 slowdown_pct_min;
60 bool bpoison;
61};
62
63struct clk_freq_controllers {
64 struct boardobjgrp_e32 super;
65 u32 sampling_period_ms;
66 struct boardobjgrpmask_e32 freq_ctrl_load_mask;
67 u8 volt_policy_idx;
68 void *pprereq_load;
69};
70
71u32 clk_freq_controller_sw_setup(struct gk20a *g);
72u32 clk_freq_controller_pmu_setup(struct gk20a *g);
73
74#endif
diff --git a/drivers/gpu/nvgpu/clk/clk_mclk.c b/drivers/gpu/nvgpu/clk/clk_mclk.c
new file mode 100644
index 00000000..06ff9082
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_mclk.c
@@ -0,0 +1,2499 @@
1/*
2 * Copyright (c) 2014-2016, 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
14#include "gk20a/gk20a.h"
15#include <linux/delay.h>
16#include "pmuif/gpmuifseq.h"
17#include "gm206/bios_gm206.h"
18#include "gk20a/pmu_gk20a.h"
19#include "gk20a/hw_pwr_gk20a.h"
20#include "gp106/hw_fb_gp106.h"
21
22#include "include/bios.h"
23
24#define VREG_COUNT 24
25
26struct memory_link_training_pattern {
27 u32 regaddr;
28 u32 writeval;
29};
30
31static struct memory_link_training_pattern memory_pattern_reglist[] = {
32 {0x9a0968, 0x0},
33 {0x9a0920, 0x0},
34 {0x9a0918, 0x0},
35 {0x9a0920, 0x100},
36 {0x9a0918, 0x0},
37 {0x9a096c, 0x0},
38 {0x9a0924, 0x0},
39 {0x9a091c, 0x0},
40 {0x9a0924, 0x100},
41 {0x9a091c, 0x0},
42 {0x9a0968, 0x100},
43 {0x9a0920, 0xff},
44 {0x9a0918, 0xffffffff},
45 {0x9a0920, 0x1ff},
46 {0x9a0918, 0xffffffff},
47 {0x9a096c, 0x100},
48 {0x9a0924, 0xff},
49 {0x9a091c, 0xffffffff},
50 {0x9a0924, 0x1ff},
51 {0x9a091c, 0xffffffff},
52 {0x9a0968, 0x200},
53 {0x9a0920, 0xff},
54 {0x9a0918, 0x55555555},
55 {0x9a0920, 0x1ff},
56 {0x9a0918, 0x55555555},
57 {0x9a096c, 0x200},
58 {0x9a0924, 0xff},
59 {0x9a091c, 0x55555555},
60 {0x9a0924, 0x1ff},
61 {0x9a091c, 0x55555555},
62 {0x9a0968, 0x300},
63 {0x9a0920, 0x0},
64 {0x9a0918, 0xaaaaaaaa},
65 {0x9a0920, 0x100},
66 {0x9a0918, 0xaaaaaaaa},
67 {0x9a096c, 0x300},
68 {0x9a0924, 0x0},
69 {0x9a091c, 0xaaaaaaaa},
70 {0x9a0924, 0x100},
71 {0x9a091c, 0xaaaaaaaa},
72 {0x9a0968, 0x400},
73 {0x9a0920, 0xff},
74 {0x9a0918, 0x33333333},
75 {0x9a0920, 0x1ff},
76 {0x9a0918, 0x33333333},
77 {0x9a096c, 0x400},
78 {0x9a0924, 0xff},
79 {0x9a091c, 0x33333333},
80 {0x9a0924, 0x1ff},
81 {0x9a091c, 0x33333333},
82 {0x9a0968, 0x500},
83 {0x9a0920, 0x0},
84 {0x9a0918, 0xcccccccc},
85 {0x9a0920, 0x100},
86 {0x9a0918, 0xcccccccc},
87 {0x9a096c, 0x500},
88 {0x9a0924, 0x0},
89 {0x9a091c, 0xcccccccc},
90 {0x9a0924, 0x100},
91 {0x9a091c, 0xcccccccc},
92 {0x9a0968, 0x600},
93 {0x9a0920, 0x0},
94 {0x9a0918, 0xf0f0f0f0},
95 {0x9a0920, 0x100},
96 {0x9a0918, 0xf0f0f0f0},
97 {0x9a096c, 0x600},
98 {0x9a0924, 0x0},
99 {0x9a091c, 0xf0f0f0f0},
100 {0x9a0924, 0x100},
101 {0x9a091c, 0xf0f0f0f0},
102 {0x9a0968, 0x700},
103 {0x9a0920, 0xff},
104 {0x9a0918, 0xf0f0f0f},
105 {0x9a0920, 0x1ff},
106 {0x9a0918, 0xf0f0f0f},
107 {0x9a096c, 0x700},
108 {0x9a0924, 0xff},
109 {0x9a091c, 0xf0f0f0f},
110 {0x9a0924, 0x1ff},
111 {0x9a091c, 0xf0f0f0f},
112 {0x9a0968, 0x800},
113 {0x9a0920, 0xff},
114 {0x9a0918, 0xff00ff},
115 {0x9a0920, 0x1ff},
116 {0x9a0918, 0xff00ff},
117 {0x9a096c, 0x800},
118 {0x9a0924, 0xff},
119 {0x9a091c, 0xff00ff},
120 {0x9a0924, 0x1ff},
121 {0x9a091c, 0xff00ff},
122 {0x9a0968, 0x900},
123 {0x9a0920, 0x0},
124 {0x9a0918, 0xff00ff00},
125 {0x9a0920, 0x100},
126 {0x9a0918, 0xff00ff00},
127 {0x9a096c, 0x900},
128 {0x9a0924, 0x0},
129 {0x9a091c, 0xff00ff00},
130 {0x9a0924, 0x100},
131 {0x9a091c, 0xff00ff00},
132 {0x9a0968, 0xa00},
133 {0x9a0920, 0xff},
134 {0x9a0918, 0xffff},
135 {0x9a0920, 0x1ff},
136 {0x9a0918, 0xffff},
137 {0x9a096c, 0xa00},
138 {0x9a0924, 0xff},
139 {0x9a091c, 0xffff},
140 {0x9a0924, 0x1ff},
141 {0x9a091c, 0xffff},
142 {0x9a0968, 0xb00},
143 {0x9a0920, 0x0},
144 {0x9a0918, 0xffff0000},
145 {0x9a0920, 0x100},
146 {0x9a0918, 0xffff0000},
147 {0x9a096c, 0xb00},
148 {0x9a0924, 0x0},
149 {0x9a091c, 0xffff0000},
150 {0x9a0924, 0x100},
151 {0x9a091c, 0xffff0000},
152 {0x9a0968, 0xc00},
153 {0x9a0920, 0x0},
154 {0x9a0918, 0x0},
155 {0x9a0920, 0x100},
156 {0x9a0918, 0x0},
157 {0x9a096c, 0xc00},
158 {0x9a0924, 0x0},
159 {0x9a091c, 0x0},
160 {0x9a0924, 0x100},
161 {0x9a091c, 0x0},
162 {0x9a0968, 0xd00},
163 {0x9a0920, 0xff},
164 {0x9a0918, 0xffffffff},
165 {0x9a0920, 0x1ff},
166 {0x9a0918, 0xffffffff},
167 {0x9a096c, 0xd00},
168 {0x9a0924, 0xff},
169 {0x9a091c, 0xffffffff},
170 {0x9a0924, 0x1ff},
171 {0x9a091c, 0xffffffff},
172 {0x9a0968, 0xe00},
173 {0x9a0920, 0xff},
174 {0x9a0918, 0x55555555},
175 {0x9a0920, 0x1ff},
176 {0x9a0918, 0x55555555},
177 {0x9a096c, 0xe00},
178 {0x9a0924, 0xff},
179 {0x9a091c, 0x55555555},
180 {0x9a0924, 0x1ff},
181 {0x9a091c, 0x55555555},
182 {0x9a0968, 0xf00},
183 {0x9a0920, 0x0},
184 {0x9a0918, 0xaaaaaaaa},
185 {0x9a0920, 0x100},
186 {0x9a0918, 0xaaaaaaaa},
187 {0x9a096c, 0xf00},
188 {0x9a0924, 0x0},
189 {0x9a091c, 0xaaaaaaaa},
190 {0x9a0924, 0x100},
191 {0x9a091c, 0xaaaaaaaa},
192 {0x9a0968, 0x1000},
193 {0x9a0920, 0xff},
194 {0x9a0918, 0x33333333},
195 {0x9a0920, 0x1ff},
196 {0x9a0918, 0x33333333},
197 {0x9a096c, 0x1000},
198 {0x9a0924, 0xff},
199 {0x9a091c, 0x33333333},
200 {0x9a0924, 0x1ff},
201 {0x9a091c, 0x33333333},
202 {0x9a0968, 0x1100},
203 {0x9a0920, 0x0},
204 {0x9a0918, 0xcccccccc},
205 {0x9a0920, 0x100},
206 {0x9a0918, 0xcccccccc},
207 {0x9a096c, 0x1100},
208 {0x9a0924, 0x0},
209 {0x9a091c, 0xcccccccc},
210 {0x9a0924, 0x100},
211 {0x9a091c, 0xcccccccc},
212 {0x9a0968, 0x1200},
213 {0x9a0920, 0x0},
214 {0x9a0918, 0xf0f0f0f0},
215 {0x9a0920, 0x100},
216 {0x9a0918, 0xf0f0f0f0},
217 {0x9a096c, 0x1200},
218 {0x9a0924, 0x0},
219 {0x9a091c, 0xf0f0f0f0},
220 {0x9a0924, 0x100},
221 {0x9a091c, 0xf0f0f0f0},
222 {0x9a0968, 0x1300},
223 {0x9a0920, 0xff},
224 {0x9a0918, 0xf0f0f0f},
225 {0x9a0920, 0x1ff},
226 {0x9a0918, 0xf0f0f0f},
227 {0x9a096c, 0x1300},
228 {0x9a0924, 0xff},
229 {0x9a091c, 0xf0f0f0f},
230 {0x9a0924, 0x1ff},
231 {0x9a091c, 0xf0f0f0f},
232 {0x9a0968, 0x1400},
233 {0x9a0920, 0xff},
234 {0x9a0918, 0xff00ff},
235 {0x9a0920, 0x1ff},
236 {0x9a0918, 0xff00ff},
237 {0x9a096c, 0x1400},
238 {0x9a0924, 0xff},
239 {0x9a091c, 0xff00ff},
240 {0x9a0924, 0x1ff},
241 {0x9a091c, 0xff00ff},
242 {0x9a0968, 0x1500},
243 {0x9a0920, 0x0},
244 {0x9a0918, 0xff00ff00},
245 {0x9a0920, 0x100},
246 {0x9a0918, 0xff00ff00},
247 {0x9a096c, 0x1500},
248 {0x9a0924, 0x0},
249 {0x9a091c, 0xff00ff00},
250 {0x9a0924, 0x100},
251 {0x9a091c, 0xff00ff00},
252 {0x9a0968, 0x1600},
253 {0x9a0920, 0xff},
254 {0x9a0918, 0xffff},
255 {0x9a0920, 0x1ff},
256 {0x9a0918, 0xffff},
257 {0x9a096c, 0x1600},
258 {0x9a0924, 0xff},
259 {0x9a091c, 0xffff},
260 {0x9a0924, 0x1ff},
261 {0x9a091c, 0xffff},
262 {0x9a0968, 0x1700},
263 {0x9a0920, 0x0},
264 {0x9a0918, 0xffff0000},
265 {0x9a0920, 0x100},
266 {0x9a0918, 0xffff0000},
267 {0x9a096c, 0x1700},
268 {0x9a0924, 0x0},
269 {0x9a091c, 0xffff0000},
270 {0x9a0924, 0x100},
271 {0x9a091c, 0xffff0000},
272 {0x9a0968, 0x1800},
273 {0x9a0920, 0x0},
274 {0x9a0918, 0x0},
275 {0x9a0920, 0x100},
276 {0x9a0918, 0x0},
277 {0x9a096c, 0x1800},
278 {0x9a0924, 0x0},
279 {0x9a091c, 0x0},
280 {0x9a0924, 0x100},
281 {0x9a091c, 0x0},
282 {0x9a0968, 0x1900},
283 {0x9a0920, 0xff},
284 {0x9a0918, 0xffffffff},
285 {0x9a0920, 0x1ff},
286 {0x9a0918, 0xffffffff},
287 {0x9a096c, 0x1900},
288 {0x9a0924, 0xff},
289 {0x9a091c, 0xffffffff},
290 {0x9a0924, 0x1ff},
291 {0x9a091c, 0xffffffff},
292 {0x9a0968, 0x1a00},
293 {0x9a0920, 0xff},
294 {0x9a0918, 0x55555555},
295 {0x9a0920, 0x1ff},
296 {0x9a0918, 0x55555555},
297 {0x9a096c, 0x1a00},
298 {0x9a0924, 0xff},
299 {0x9a091c, 0x55555555},
300 {0x9a0924, 0x1ff},
301 {0x9a091c, 0x55555555},
302 {0x9a0968, 0x1b00},
303 {0x9a0920, 0x0},
304 {0x9a0918, 0xaaaaaaaa},
305 {0x9a0920, 0x100},
306 {0x9a0918, 0xaaaaaaaa},
307 {0x9a096c, 0x1b00},
308 {0x9a0924, 0x0},
309 {0x9a091c, 0xaaaaaaaa},
310 {0x9a0924, 0x100},
311 {0x9a091c, 0xaaaaaaaa},
312 {0x9a0968, 0x1c00},
313 {0x9a0920, 0xff},
314 {0x9a0918, 0x33333333},
315 {0x9a0920, 0x1ff},
316 {0x9a0918, 0x33333333},
317 {0x9a096c, 0x1c00},
318 {0x9a0924, 0xff},
319 {0x9a091c, 0x33333333},
320 {0x9a0924, 0x1ff},
321 {0x9a091c, 0x33333333},
322 {0x9a0968, 0x1d00},
323 {0x9a0920, 0x0},
324 {0x9a0918, 0xcccccccc},
325 {0x9a0920, 0x100},
326 {0x9a0918, 0xcccccccc},
327 {0x9a096c, 0x1d00},
328 {0x9a0924, 0x0},
329 {0x9a091c, 0xcccccccc},
330 {0x9a0924, 0x100},
331 {0x9a091c, 0xcccccccc},
332 {0x9a0968, 0x1e00},
333 {0x9a0920, 0x0},
334 {0x9a0918, 0xf0f0f0f0},
335 {0x9a0920, 0x100},
336 {0x9a0918, 0xf0f0f0f0},
337 {0x9a096c, 0x1e00},
338 {0x9a0924, 0x0},
339 {0x9a091c, 0xf0f0f0f0},
340 {0x9a0924, 0x100},
341 {0x9a091c, 0xf0f0f0f0},
342 {0x9a0968, 0x1f00},
343 {0x9a0920, 0xff},
344 {0x9a0918, 0xf0f0f0f},
345 {0x9a0920, 0x1ff},
346 {0x9a0918, 0xf0f0f0f},
347 {0x9a096c, 0x1f00},
348 {0x9a0924, 0xff},
349 {0x9a091c, 0xf0f0f0f},
350 {0x9a0924, 0x1ff},
351 {0x9a091c, 0xf0f0f0f},
352 {0x9a0968, 0x2000},
353 {0x9a0920, 0xff},
354 {0x9a0918, 0xff00ff},
355 {0x9a0920, 0x1ff},
356 {0x9a0918, 0xff00ff},
357 {0x9a096c, 0x2000},
358 {0x9a0924, 0xff},
359 {0x9a091c, 0xff00ff},
360 {0x9a0924, 0x1ff},
361 {0x9a091c, 0xff00ff},
362 {0x9a0968, 0x2100},
363 {0x9a0920, 0x0},
364 {0x9a0918, 0xff00ff00},
365 {0x9a0920, 0x100},
366 {0x9a0918, 0xff00ff00},
367 {0x9a096c, 0x2100},
368 {0x9a0924, 0x0},
369 {0x9a091c, 0xff00ff00},
370 {0x9a0924, 0x100},
371 {0x9a091c, 0xff00ff00},
372 {0x9a0968, 0x2200},
373 {0x9a0920, 0xff},
374 {0x9a0918, 0xffff},
375 {0x9a0920, 0x1ff},
376 {0x9a0918, 0xffff},
377 {0x9a096c, 0x2200},
378 {0x9a0924, 0xff},
379 {0x9a091c, 0xffff},
380 {0x9a0924, 0x1ff},
381 {0x9a091c, 0xffff},
382 {0x9a0968, 0x2300},
383 {0x9a0920, 0x0},
384 {0x9a0918, 0xffff0000},
385 {0x9a0920, 0x100},
386 {0x9a0918, 0xffff0000},
387 {0x9a096c, 0x2300},
388 {0x9a0924, 0x0},
389 {0x9a091c, 0xffff0000},
390 {0x9a0924, 0x100},
391 {0x9a091c, 0xffff0000},
392 {0x9a0968, 0x2400},
393 {0x9a0920, 0x0},
394 {0x9a0918, 0x0},
395 {0x9a0920, 0x100},
396 {0x9a0918, 0x0},
397 {0x9a096c, 0x2400},
398 {0x9a0924, 0x0},
399 {0x9a091c, 0x0},
400 {0x9a0924, 0x100},
401 {0x9a091c, 0x0},
402 {0x9a0968, 0x2500},
403 {0x9a0920, 0xff},
404 {0x9a0918, 0xffffffff},
405 {0x9a0920, 0x1ff},
406 {0x9a0918, 0xffffffff},
407 {0x9a096c, 0x2500},
408 {0x9a0924, 0xff},
409 {0x9a091c, 0xffffffff},
410 {0x9a0924, 0x1ff},
411 {0x9a091c, 0xffffffff},
412 {0x9a0968, 0x2600},
413 {0x9a0920, 0xff},
414 {0x9a0918, 0x55555555},
415 {0x9a0920, 0x1ff},
416 {0x9a0918, 0x55555555},
417 {0x9a096c, 0x2600},
418 {0x9a0924, 0xff},
419 {0x9a091c, 0x55555555},
420 {0x9a0924, 0x1ff},
421 {0x9a091c, 0x55555555},
422 {0x9a0968, 0x2700},
423 {0x9a0920, 0x0},
424 {0x9a0918, 0xaaaaaaaa},
425 {0x9a0920, 0x100},
426 {0x9a0918, 0xaaaaaaaa},
427 {0x9a096c, 0x2700},
428 {0x9a0924, 0x0},
429 {0x9a091c, 0xaaaaaaaa},
430 {0x9a0924, 0x100},
431 {0x9a091c, 0xaaaaaaaa},
432 {0x9a0968, 0x2800},
433 {0x9a0920, 0xff},
434 {0x9a0918, 0x33333333},
435 {0x9a0920, 0x1ff},
436 {0x9a0918, 0x33333333},
437 {0x9a096c, 0x2800},
438 {0x9a0924, 0xff},
439 {0x9a091c, 0x33333333},
440 {0x9a0924, 0x1ff},
441 {0x9a091c, 0x33333333},
442 {0x9a0968, 0x2900},
443 {0x9a0920, 0x0},
444 {0x9a0918, 0xcccccccc},
445 {0x9a0920, 0x100},
446 {0x9a0918, 0xcccccccc},
447 {0x9a096c, 0x2900},
448 {0x9a0924, 0x0},
449 {0x9a091c, 0xcccccccc},
450 {0x9a0924, 0x100},
451 {0x9a091c, 0xcccccccc},
452 {0x9a0968, 0x2a00},
453 {0x9a0920, 0x0},
454 {0x9a0918, 0xf0f0f0f0},
455 {0x9a0920, 0x100},
456 {0x9a0918, 0xf0f0f0f0},
457 {0x9a096c, 0x2a00},
458 {0x9a0924, 0x0},
459 {0x9a091c, 0xf0f0f0f0},
460 {0x9a0924, 0x100},
461 {0x9a091c, 0xf0f0f0f0},
462 {0x9a0968, 0x2b00},
463 {0x9a0920, 0xff},
464 {0x9a0918, 0xf0f0f0f},
465 {0x9a0920, 0x1ff},
466 {0x9a0918, 0xf0f0f0f},
467 {0x9a096c, 0x2b00},
468 {0x9a0924, 0xff},
469 {0x9a091c, 0xf0f0f0f},
470 {0x9a0924, 0x1ff},
471 {0x9a091c, 0xf0f0f0f},
472 {0x9a0968, 0x2c00},
473 {0x9a0920, 0xff},
474 {0x9a0918, 0xff00ff},
475 {0x9a0920, 0x1ff},
476 {0x9a0918, 0xff00ff},
477 {0x9a096c, 0x2c00},
478 {0x9a0924, 0xff},
479 {0x9a091c, 0xff00ff},
480 {0x9a0924, 0x1ff},
481 {0x9a091c, 0xff00ff},
482 {0x9a0968, 0x2d00},
483 {0x9a0920, 0x0},
484 {0x9a0918, 0xff00ff00},
485 {0x9a0920, 0x100},
486 {0x9a0918, 0xff00ff00},
487 {0x9a096c, 0x2d00},
488 {0x9a0924, 0x0},
489 {0x9a091c, 0xff00ff00},
490 {0x9a0924, 0x100},
491 {0x9a091c, 0xff00ff00},
492 {0x9a0968, 0x2e00},
493 {0x9a0920, 0xff},
494 {0x9a0918, 0xffff},
495 {0x9a0920, 0x1ff},
496 {0x9a0918, 0xffff},
497 {0x9a096c, 0x2e00},
498 {0x9a0924, 0xff},
499 {0x9a091c, 0xffff},
500 {0x9a0924, 0x1ff},
501 {0x9a091c, 0xffff},
502 {0x9a0968, 0x2f00},
503 {0x9a0920, 0x0},
504 {0x9a0918, 0xffff0000},
505 {0x9a0920, 0x100},
506 {0x9a0918, 0xffff0000},
507 {0x9a096c, 0x2f00},
508 {0x9a0924, 0x0},
509 {0x9a091c, 0xffff0000},
510 {0x9a0924, 0x100},
511 {0x9a091c, 0xffff0000},
512 {0x9a0968, 0x0},
513 {0x9a0900, 0x0},
514 {0x9a0968, 0x1},
515 {0x9a0900, 0xffffffff},
516 {0x9a0968, 0x2},
517 {0x9a0900, 0x0},
518 {0x9a0968, 0x3},
519 {0x9a0900, 0xffffffff},
520 {0x9a0968, 0x4},
521 {0x9a0900, 0x0},
522 {0x9a0968, 0x5},
523 {0x9a0900, 0xffffffff},
524 {0x9a0968, 0x6},
525 {0x9a0900, 0x0},
526 {0x9a0968, 0x7},
527 {0x9a0900, 0xffffffff},
528 {0x9a0968, 0x8},
529 {0x9a0900, 0x0},
530 {0x9a0968, 0x9},
531 {0x9a0900, 0xffffffff},
532 {0x9a0968, 0xa},
533 {0x9a0900, 0x0},
534 {0x9a0968, 0xb},
535 {0x9a0900, 0xffffffff},
536 {0x9a0968, 0xc},
537 {0x9a0900, 0x0},
538 {0x9a0968, 0xd},
539 {0x9a0900, 0xffffffff},
540 {0x9a0968, 0xe},
541 {0x9a0900, 0x0},
542 {0x9a0968, 0xf},
543 {0x9a0900, 0xffffffff},
544 {0x9a0968, 0x10},
545 {0x9a0900, 0x55555555},
546 {0x9a0968, 0x11},
547 {0x9a0900, 0xaaaaaaaa},
548 {0x9a0968, 0x12},
549 {0x9a0900, 0x55555555},
550 {0x9a0968, 0x13},
551 {0x9a0900, 0xaaaaaaaa},
552 {0x9a0968, 0x14},
553 {0x9a0900, 0x55555555},
554 {0x9a0968, 0x15},
555 {0x9a0900, 0xaaaaaaaa},
556 {0x9a0968, 0x16},
557 {0x9a0900, 0x55555555},
558 {0x9a0968, 0x17},
559 {0x9a0900, 0xaaaaaaaa},
560 {0x9a0968, 0x18},
561 {0x9a0900, 0x55555555},
562 {0x9a0968, 0x19},
563 {0x9a0900, 0xaaaaaaaa},
564 {0x9a0968, 0x1a},
565 {0x9a0900, 0x55555555},
566 {0x9a0968, 0x1b},
567 {0x9a0900, 0xaaaaaaaa},
568 {0x9a0968, 0x1c},
569 {0x9a0900, 0x55555555},
570 {0x9a0968, 0x1d},
571 {0x9a0900, 0xaaaaaaaa},
572 {0x9a0968, 0x1e},
573 {0x9a0900, 0x55555555},
574 {0x9a0968, 0x1f},
575 {0x9a0900, 0xaaaaaaaa},
576 {0x9a0968, 0x20},
577 {0x9a0900, 0xffff},
578 {0x9a0968, 0x21},
579 {0x9a0900, 0xffff0000},
580 {0x9a0968, 0x22},
581 {0x9a0900, 0xffff},
582 {0x9a0968, 0x23},
583 {0x9a0900, 0xffff0000},
584 {0x9a0968, 0x24},
585 {0x9a0900, 0xffff},
586 {0x9a0968, 0x25},
587 {0x9a0900, 0xffff0000},
588 {0x9a0968, 0x26},
589 {0x9a0900, 0xffff},
590 {0x9a0968, 0x27},
591 {0x9a0900, 0xffff0000},
592 {0x9a0968, 0x28},
593 {0x9a0900, 0xffff},
594 {0x9a0968, 0x29},
595 {0x9a0900, 0xffff0000},
596 {0x9a0968, 0x2a},
597 {0x9a0900, 0xffff},
598 {0x9a0968, 0x2b},
599 {0x9a0900, 0xffff0000},
600 {0x9a0968, 0x2c},
601 {0x9a0900, 0xffff},
602 {0x9a0968, 0x2d},
603 {0x9a0900, 0xffff0000},
604 {0x9a0968, 0x2e},
605 {0x9a0900, 0xffff},
606 {0x9a0968, 0x2f},
607 {0x9a0900, 0xffff0000},
608 {0x9a0968, 0x30},
609 {0x9a0900, 0xff00ff},
610 {0x9a0968, 0x31},
611 {0x9a0900, 0xff00ff00},
612 {0x9a0968, 0x32},
613 {0x9a0900, 0xff00ff},
614 {0x9a0968, 0x33},
615 {0x9a0900, 0xff00ff00},
616 {0x9a0968, 0x34},
617 {0x9a0900, 0xff00ff},
618 {0x9a0968, 0x35},
619 {0x9a0900, 0xff00ff00},
620 {0x9a0968, 0x36},
621 {0x9a0900, 0xff00ff},
622 {0x9a0968, 0x37},
623 {0x9a0900, 0xff00ff00},
624 {0x9a0968, 0x38},
625 {0x9a0900, 0xff00ff},
626 {0x9a0968, 0x39},
627 {0x9a0900, 0xff00ff00},
628 {0x9a0968, 0x3a},
629 {0x9a0900, 0xff00ff},
630 {0x9a0968, 0x3b},
631 {0x9a0900, 0xff00ff00},
632 {0x9a0968, 0x3c},
633 {0x9a0900, 0xff00ff},
634 {0x9a0968, 0x3d},
635 {0x9a0900, 0xff00ff00},
636 {0x9a0968, 0x3e},
637 {0x9a0900, 0xff00ff},
638 {0x9a0968, 0x3f},
639 {0x9a0900, 0xff00ff00},
640 {0x9a0968, 0x40},
641 {0x9a0900, 0x0},
642 {0x9a0968, 0x41},
643 {0x9a0900, 0xffffffff},
644 {0x9a0968, 0x42},
645 {0x9a0900, 0x0},
646 {0x9a0968, 0x43},
647 {0x9a0900, 0xffffffff},
648 {0x9a0968, 0x44},
649 {0x9a0900, 0x0},
650 {0x9a0968, 0x45},
651 {0x9a0900, 0xffffffff},
652 {0x9a0968, 0x46},
653 {0x9a0900, 0x0},
654 {0x9a0968, 0x47},
655 {0x9a0900, 0xffffffff},
656 {0x9a0968, 0x48},
657 {0x9a0900, 0x0},
658 {0x9a0968, 0x49},
659 {0x9a0900, 0xffffffff},
660 {0x9a0968, 0x4a},
661 {0x9a0900, 0x0},
662 {0x9a0968, 0x4b},
663 {0x9a0900, 0xffffffff},
664 {0x9a0968, 0x4c},
665 {0x9a0900, 0x0},
666 {0x9a0968, 0x4d},
667 {0x9a0900, 0xffffffff},
668 {0x9a0968, 0x4e},
669 {0x9a0900, 0x0},
670 {0x9a0968, 0x4f},
671 {0x9a0900, 0xffffffff},
672 {0x9a0968, 0x50},
673 {0x9a0900, 0x55555555},
674 {0x9a0968, 0x51},
675 {0x9a0900, 0xaaaaaaaa},
676 {0x9a0968, 0x52},
677 {0x9a0900, 0x55555555},
678 {0x9a0968, 0x53},
679 {0x9a0900, 0xaaaaaaaa},
680 {0x9a0968, 0x54},
681 {0x9a0900, 0x55555555},
682 {0x9a0968, 0x55},
683 {0x9a0900, 0xaaaaaaaa},
684 {0x9a0968, 0x56},
685 {0x9a0900, 0x55555555},
686 {0x9a0968, 0x57},
687 {0x9a0900, 0xaaaaaaaa},
688 {0x9a0968, 0x58},
689 {0x9a0900, 0x55555555},
690 {0x9a0968, 0x59},
691 {0x9a0900, 0xaaaaaaaa},
692 {0x9a0968, 0x5a},
693 {0x9a0900, 0x55555555},
694 {0x9a0968, 0x5b},
695 {0x9a0900, 0xaaaaaaaa},
696 {0x9a0968, 0x5c},
697 {0x9a0900, 0x55555555},
698 {0x9a0968, 0x5d},
699 {0x9a0900, 0xaaaaaaaa},
700 {0x9a0968, 0x5e},
701 {0x9a0900, 0x55555555},
702 {0x9a0968, 0x5f},
703 {0x9a0900, 0x0},
704 {0x9a0968, 0x60},
705 {0x9a0900, 0xffffffff},
706 {0x9a0968, 0x61},
707 {0x9a0900, 0x0},
708 {0x9a0968, 0x62},
709 {0x9a0900, 0xffffffff},
710 {0x9a0968, 0x63},
711 {0x9a0900, 0x0},
712 {0x9a0968, 0x64},
713 {0x9a0900, 0xffffffff},
714 {0x9a0968, 0x65},
715 {0x9a0900, 0x0},
716 {0x9a0968, 0x66},
717 {0x9a0900, 0xffffffff},
718 {0x9a0968, 0x67},
719 {0x9a0900, 0x0},
720 {0x9a0968, 0x68},
721 {0x9a0900, 0xffffffff},
722 {0x9a0968, 0x69},
723 {0x9a0900, 0x0},
724 {0x9a0968, 0x6a},
725 {0x9a0900, 0xffffffff},
726 {0x9a0968, 0x6b},
727 {0x9a0900, 0x0},
728 {0x9a0968, 0x6c},
729 {0x9a0900, 0xffffffff},
730 {0x9a0968, 0x6d},
731 {0x9a0900, 0x0},
732 {0x9a0968, 0x6e},
733 {0x9a0900, 0xffffffff},
734 {0x9a0968, 0x6f},
735 {0x9a0900, 0x55555555},
736 {0x9a0968, 0x70},
737 {0x9a0900, 0xaaaaaaaa},
738 {0x9a0968, 0x71},
739 {0x9a0900, 0x55555555},
740 {0x9a0968, 0x72},
741 {0x9a0900, 0xaaaaaaaa},
742 {0x9a0968, 0x73},
743 {0x9a0900, 0x55555555},
744 {0x9a0968, 0x74},
745 {0x9a0900, 0xaaaaaaaa},
746 {0x9a0968, 0x75},
747 {0x9a0900, 0x55555555},
748 {0x9a0968, 0x76},
749 {0x9a0900, 0xaaaaaaaa},
750 {0x9a0968, 0x77},
751 {0x9a0900, 0x55555555},
752 {0x9a0968, 0x78},
753 {0x9a0900, 0xaaaaaaaa},
754 {0x9a0968, 0x79},
755 {0x9a0900, 0x55555555},
756 {0x9a0968, 0x7a},
757 {0x9a0900, 0xaaaaaaaa},
758 {0x9a0968, 0x7b},
759 {0x9a0900, 0x55555555},
760 {0x9a0968, 0x7c},
761 {0x9a0900, 0xaaaaaaaa},
762 {0x9a0968, 0x7d},
763 {0x9a0900, 0x55555555},
764 {0x9a0968, 0x7e},
765 {0x9a0900, 0xaaaaaaaa},
766 {0x9a0968, 0x7f},
767 {0x9a0900, 0xffff},
768 {0x9a0968, 0x80},
769 {0x9a0900, 0xffff0000},
770 {0x9a0968, 0x81},
771 {0x9a0900, 0xffff},
772 {0x9a0968, 0x82},
773 {0x9a0900, 0xffff0000},
774 {0x9a0968, 0x83},
775 {0x9a0900, 0xffff},
776 {0x9a0968, 0x84},
777 {0x9a0900, 0xffff0000},
778 {0x9a0968, 0x85},
779 {0x9a0900, 0xffff},
780 {0x9a0968, 0x86},
781 {0x9a0900, 0xffff0000},
782 {0x9a0968, 0x87},
783 {0x9a0900, 0xffff},
784 {0x9a0968, 0x88},
785 {0x9a0900, 0xffff0000},
786 {0x9a0968, 0x89},
787 {0x9a0900, 0xffff},
788 {0x9a0968, 0x8a},
789 {0x9a0900, 0xffff0000},
790 {0x9a0968, 0x8b},
791 {0x9a0900, 0xffff},
792 {0x9a0968, 0x8c},
793 {0x9a0900, 0xffff0000},
794 {0x9a0968, 0x8d},
795 {0x9a0900, 0xffff},
796 {0x9a0968, 0x8e},
797 {0x9a0900, 0xffff0000},
798 {0x9a0968, 0x8f},
799 {0x9a0900, 0xff00ff},
800 {0x9a0968, 0x90},
801 {0x9a0900, 0xff00ff00},
802 {0x9a0968, 0x91},
803 {0x9a0900, 0xff00ff},
804 {0x9a0968, 0x92},
805 {0x9a0900, 0xff00ff00},
806 {0x9a0968, 0x93},
807 {0x9a0900, 0xff00ff},
808 {0x9a0968, 0x94},
809 {0x9a0900, 0xff00ff00},
810 {0x9a0968, 0x95},
811 {0x9a0900, 0xff00ff},
812 {0x9a0968, 0x96},
813 {0x9a0900, 0xff00ff00},
814 {0x9a0968, 0x97},
815 {0x9a0900, 0xff00ff},
816 {0x9a0968, 0x98},
817 {0x9a0900, 0xff00ff00},
818 {0x9a0968, 0x99},
819 {0x9a0900, 0xff00ff},
820 {0x9a0968, 0x9a},
821 {0x9a0900, 0xff00ff00},
822 {0x9a0968, 0x9b},
823 {0x9a0900, 0xff00ff},
824 {0x9a0968, 0x9c},
825 {0x9a0900, 0xff00ff00},
826 {0x9a0968, 0x9d},
827 {0x9a0900, 0xff00ff},
828 {0x9a0968, 0x9e},
829 {0x9a0900, 0xff00ff00},
830 {0x9a0968, 0x9f},
831 {0x9a0900, 0x0},
832 {0x9a0968, 0xa0},
833 {0x9a0900, 0xffffffff},
834 {0x9a0968, 0xa1},
835 {0x9a0900, 0x0},
836 {0x9a0968, 0xa2},
837 {0x9a0900, 0xffffffff},
838 {0x9a0968, 0xa3},
839 {0x9a0900, 0x0},
840 {0x9a0968, 0xa4},
841 {0x9a0900, 0xffffffff},
842 {0x9a0968, 0xa5},
843 {0x9a0900, 0x0},
844 {0x9a0968, 0xa6},
845 {0x9a0900, 0xffffffff},
846 {0x9a0968, 0xa7},
847 {0x9a0900, 0x0},
848 {0x9a0968, 0xa8},
849 {0x9a0900, 0xffffffff},
850 {0x9a0968, 0xa9},
851 {0x9a0900, 0x0},
852 {0x9a0968, 0xaa},
853 {0x9a0900, 0xffffffff},
854 {0x9a0968, 0xab},
855 {0x9a0900, 0x0},
856 {0x9a0968, 0xac},
857 {0x9a0900, 0xffffffff},
858 {0x9a0968, 0xad},
859 {0x9a0900, 0x0},
860 {0x9a0968, 0xae},
861 {0x9a0900, 0xffffffff},
862 {0x9a0968, 0xaf},
863 {0x9a0900, 0x55555555},
864 {0x9a0968, 0xb0},
865 {0x9a0900, 0xaaaaaaaa},
866 {0x9a0968, 0xb1},
867 {0x9a0900, 0x55555555},
868 {0x9a0968, 0xb2},
869 {0x9a0900, 0xaaaaaaaa},
870 {0x9a0968, 0xb3},
871 {0x9a0900, 0x55555555},
872 {0x9a0968, 0xb4},
873 {0x9a0900, 0xaaaaaaaa},
874 {0x9a0968, 0xb5},
875 {0x9a0900, 0x55555555},
876 {0x9a0968, 0xb6},
877 {0x9a0900, 0xaaaaaaaa},
878 {0x9a0968, 0xb7},
879 {0x9a0900, 0x55555555},
880 {0x9a0968, 0xb8},
881 {0x9a0900, 0xaaaaaaaa},
882 {0x9a0968, 0xb9},
883 {0x9a0900, 0x55555555},
884 {0x9a0968, 0xba},
885 {0x9a0900, 0xaaaaaaaa},
886 {0x9a0968, 0xbb},
887 {0x9a0900, 0x55555555},
888 {0x9a0968, 0xbc},
889 {0x9a0900, 0xaaaaaaaa},
890 {0x9a0968, 0xbd},
891 {0x9a0900, 0x55555555},
892 {0x9a0968, 0xbe},
893 {0x9a0900, 0x0},
894 {0x9a0968, 0xbf},
895 {0x9a0900, 0xffffffff},
896 {0x9a0968, 0xc0},
897 {0x9a0900, 0x0},
898 {0x9a0968, 0xc1},
899 {0x9a0900, 0xffffffff},
900 {0x9a0968, 0xc2},
901 {0x9a0900, 0x0},
902 {0x9a0968, 0xc3},
903 {0x9a0900, 0xffffffff},
904 {0x9a0968, 0xc4},
905 {0x9a0900, 0x0},
906 {0x9a0968, 0xc5},
907 {0x9a0900, 0xffffffff},
908 {0x9a0968, 0xc6},
909 {0x9a0900, 0x0},
910 {0x9a0968, 0xc7},
911 {0x9a0900, 0xffffffff},
912 {0x9a0968, 0xc8},
913 {0x9a0900, 0x0},
914 {0x9a0968, 0xc9},
915 {0x9a0900, 0xffffffff},
916 {0x9a0968, 0xca},
917 {0x9a0900, 0x0},
918 {0x9a0968, 0xcb},
919 {0x9a0900, 0xffffffff},
920 {0x9a0968, 0xcc},
921 {0x9a0900, 0x0},
922 {0x9a0968, 0xcd},
923 {0x9a0900, 0xffffffff},
924 {0x9a0968, 0xce},
925 {0x9a0900, 0x55555555},
926 {0x9a0968, 0xcf},
927 {0x9a0900, 0xaaaaaaaa},
928 {0x9a0968, 0xd0},
929 {0x9a0900, 0x55555555},
930 {0x9a0968, 0xd1},
931 {0x9a0900, 0xaaaaaaaa},
932 {0x9a0968, 0xd2},
933 {0x9a0900, 0x55555555},
934 {0x9a0968, 0xd3},
935 {0x9a0900, 0xaaaaaaaa},
936 {0x9a0968, 0xd4},
937 {0x9a0900, 0x55555555},
938 {0x9a0968, 0xd5},
939 {0x9a0900, 0xaaaaaaaa},
940 {0x9a0968, 0xd6},
941 {0x9a0900, 0x55555555},
942 {0x9a0968, 0xd7},
943 {0x9a0900, 0xaaaaaaaa},
944 {0x9a0968, 0xd8},
945 {0x9a0900, 0x55555555},
946 {0x9a0968, 0xd9},
947 {0x9a0900, 0xaaaaaaaa},
948 {0x9a0968, 0xda},
949 {0x9a0900, 0x55555555},
950 {0x9a0968, 0xdb},
951 {0x9a0900, 0xaaaaaaaa},
952 {0x9a0968, 0xdc},
953 {0x9a0900, 0x55555555},
954 {0x9a0968, 0xdd},
955 {0x9a0900, 0xaaaaaaaa},
956 {0x9a0968, 0xde},
957 {0x9a0900, 0xffff},
958 {0x9a0968, 0xdf},
959 {0x9a0900, 0xffff0000},
960 {0x9a0968, 0xe0},
961 {0x9a0900, 0xffff},
962 {0x9a0968, 0xe1},
963 {0x9a0900, 0xffff0000},
964 {0x9a0968, 0xe2},
965 {0x9a0900, 0xffff},
966 {0x9a0968, 0xe3},
967 {0x9a0900, 0xffff0000},
968 {0x9a0968, 0xe4},
969 {0x9a0900, 0xffff},
970 {0x9a0968, 0xe5},
971 {0x9a0900, 0xffff0000},
972 {0x9a0968, 0xe6},
973 {0x9a0900, 0xffff},
974 {0x9a0968, 0xe7},
975 {0x9a0900, 0xffff0000},
976 {0x9a0968, 0xe8},
977 {0x9a0900, 0xffff},
978 {0x9a0968, 0xe9},
979 {0x9a0900, 0xffff0000},
980 {0x9a0968, 0xea},
981 {0x9a0900, 0xffff},
982 {0x9a0968, 0xeb},
983 {0x9a0900, 0xffff0000},
984 {0x9a0968, 0xec},
985 {0x9a0900, 0xffff},
986 {0x9a0968, 0xed},
987 {0x9a0900, 0xffff0000},
988 {0x9a0968, 0xee},
989 {0x9a0900, 0xff00ff},
990 {0x9a0968, 0xef},
991 {0x9a0900, 0xff00ff00},
992 {0x9a0968, 0xf0},
993 {0x9a0900, 0xff00ff},
994 {0x9a0968, 0xf1},
995 {0x9a0900, 0xff00ff00},
996 {0x9a0968, 0xf2},
997 {0x9a0900, 0xff00ff},
998 {0x9a0968, 0xf3},
999 {0x9a0900, 0xff00ff00},
1000 {0x9a0968, 0xf4},
1001 {0x9a0900, 0xff00ff},
1002 {0x9a0968, 0xf5},
1003 {0x9a0900, 0xff00ff00},
1004 {0x9a0968, 0xf6},
1005 {0x9a0900, 0xff00ff},
1006 {0x9a0968, 0xf7},
1007 {0x9a0900, 0xff00ff00},
1008 {0x9a0968, 0xf8},
1009 {0x9a0900, 0xff00ff},
1010 {0x9a0968, 0xf9},
1011 {0x9a0900, 0xff00ff00},
1012 {0x9a0968, 0xfa},
1013 {0x9a0900, 0xff00ff},
1014 {0x9a0968, 0xfb},
1015 {0x9a0900, 0xff00ff00},
1016 {0x9a0968, 0xfc},
1017 {0x9a0900, 0xff00ff},
1018 {0x9a0968, 0xfd},
1019 {0x9a0900, 0xff00ff00},
1020 {0x9a0968, 0xfe},
1021 {0x9a0900, 0x0},
1022 {0x9a0968, 0xff},
1023 {0x9a0900, 0xffffffff},
1024 {0x9a096c, 0x0},
1025 {0x9a0904, 0x0},
1026 {0x9a096c, 0x1},
1027 {0x9a0904, 0xffffffff},
1028 {0x9a096c, 0x2},
1029 {0x9a0904, 0x0},
1030 {0x9a096c, 0x3},
1031 {0x9a0904, 0xffffffff},
1032 {0x9a096c, 0x4},
1033 {0x9a0904, 0x0},
1034 {0x9a096c, 0x5},
1035 {0x9a0904, 0xffffffff},
1036 {0x9a096c, 0x6},
1037 {0x9a0904, 0x0},
1038 {0x9a096c, 0x7},
1039 {0x9a0904, 0xffffffff},
1040 {0x9a096c, 0x8},
1041 {0x9a0904, 0x0},
1042 {0x9a096c, 0x9},
1043 {0x9a0904, 0xffffffff},
1044 {0x9a096c, 0xa},
1045 {0x9a0904, 0x0},
1046 {0x9a096c, 0xb},
1047 {0x9a0904, 0xffffffff},
1048 {0x9a096c, 0xc},
1049 {0x9a0904, 0x0},
1050 {0x9a096c, 0xd},
1051 {0x9a0904, 0xffffffff},
1052 {0x9a096c, 0xe},
1053 {0x9a0904, 0x0},
1054 {0x9a096c, 0xf},
1055 {0x9a0904, 0xffffffff},
1056 {0x9a096c, 0x10},
1057 {0x9a0904, 0x55555555},
1058 {0x9a096c, 0x11},
1059 {0x9a0904, 0xaaaaaaaa},
1060 {0x9a096c, 0x12},
1061 {0x9a0904, 0x55555555},
1062 {0x9a096c, 0x13},
1063 {0x9a0904, 0xaaaaaaaa},
1064 {0x9a096c, 0x14},
1065 {0x9a0904, 0x55555555},
1066 {0x9a096c, 0x15},
1067 {0x9a0904, 0xaaaaaaaa},
1068 {0x9a096c, 0x16},
1069 {0x9a0904, 0x55555555},
1070 {0x9a096c, 0x17},
1071 {0x9a0904, 0xaaaaaaaa},
1072 {0x9a096c, 0x18},
1073 {0x9a0904, 0x55555555},
1074 {0x9a096c, 0x19},
1075 {0x9a0904, 0xaaaaaaaa},
1076 {0x9a096c, 0x1a},
1077 {0x9a0904, 0x55555555},
1078 {0x9a096c, 0x1b},
1079 {0x9a0904, 0xaaaaaaaa},
1080 {0x9a096c, 0x1c},
1081 {0x9a0904, 0x55555555},
1082 {0x9a096c, 0x1d},
1083 {0x9a0904, 0xaaaaaaaa},
1084 {0x9a096c, 0x1e},
1085 {0x9a0904, 0x55555555},
1086 {0x9a096c, 0x1f},
1087 {0x9a0904, 0xaaaaaaaa},
1088 {0x9a096c, 0x20},
1089 {0x9a0904, 0xffff},
1090 {0x9a096c, 0x21},
1091 {0x9a0904, 0xffff0000},
1092 {0x9a096c, 0x22},
1093 {0x9a0904, 0xffff},
1094 {0x9a096c, 0x23},
1095 {0x9a0904, 0xffff0000},
1096 {0x9a096c, 0x24},
1097 {0x9a0904, 0xffff},
1098 {0x9a096c, 0x25},
1099 {0x9a0904, 0xffff0000},
1100 {0x9a096c, 0x26},
1101 {0x9a0904, 0xffff},
1102 {0x9a096c, 0x27},
1103 {0x9a0904, 0xffff0000},
1104 {0x9a096c, 0x28},
1105 {0x9a0904, 0xffff},
1106 {0x9a096c, 0x29},
1107 {0x9a0904, 0xffff0000},
1108 {0x9a096c, 0x2a},
1109 {0x9a0904, 0xffff},
1110 {0x9a096c, 0x2b},
1111 {0x9a0904, 0xffff0000},
1112 {0x9a096c, 0x2c},
1113 {0x9a0904, 0xffff},
1114 {0x9a096c, 0x2d},
1115 {0x9a0904, 0xffff0000},
1116 {0x9a096c, 0x2e},
1117 {0x9a0904, 0xffff},
1118 {0x9a096c, 0x2f},
1119 {0x9a0904, 0xffff0000},
1120 {0x9a096c, 0x30},
1121 {0x9a0904, 0xff00ff},
1122 {0x9a096c, 0x31},
1123 {0x9a0904, 0xff00ff00},
1124 {0x9a096c, 0x32},
1125 {0x9a0904, 0xff00ff},
1126 {0x9a096c, 0x33},
1127 {0x9a0904, 0xff00ff00},
1128 {0x9a096c, 0x34},
1129 {0x9a0904, 0xff00ff},
1130 {0x9a096c, 0x35},
1131 {0x9a0904, 0xff00ff00},
1132 {0x9a096c, 0x36},
1133 {0x9a0904, 0xff00ff},
1134 {0x9a096c, 0x37},
1135 {0x9a0904, 0xff00ff00},
1136 {0x9a096c, 0x38},
1137 {0x9a0904, 0xff00ff},
1138 {0x9a096c, 0x39},
1139 {0x9a0904, 0xff00ff00},
1140 {0x9a096c, 0x3a},
1141 {0x9a0904, 0xff00ff},
1142 {0x9a096c, 0x3b},
1143 {0x9a0904, 0xff00ff00},
1144 {0x9a096c, 0x3c},
1145 {0x9a0904, 0xff00ff},
1146 {0x9a096c, 0x3d},
1147 {0x9a0904, 0xff00ff00},
1148 {0x9a096c, 0x3e},
1149 {0x9a0904, 0xff00ff},
1150 {0x9a096c, 0x3f},
1151 {0x9a0904, 0xff00ff00},
1152 {0x9a096c, 0x40},
1153 {0x9a0904, 0x0},
1154 {0x9a096c, 0x41},
1155 {0x9a0904, 0xffffffff},
1156 {0x9a096c, 0x42},
1157 {0x9a0904, 0x0},
1158 {0x9a096c, 0x43},
1159 {0x9a0904, 0xffffffff},
1160 {0x9a096c, 0x44},
1161 {0x9a0904, 0x0},
1162 {0x9a096c, 0x45},
1163 {0x9a0904, 0xffffffff},
1164 {0x9a096c, 0x46},
1165 {0x9a0904, 0x0},
1166 {0x9a096c, 0x47},
1167 {0x9a0904, 0xffffffff},
1168 {0x9a096c, 0x48},
1169 {0x9a0904, 0x0},
1170 {0x9a096c, 0x49},
1171 {0x9a0904, 0xffffffff},
1172 {0x9a096c, 0x4a},
1173 {0x9a0904, 0x0},
1174 {0x9a096c, 0x4b},
1175 {0x9a0904, 0xffffffff},
1176 {0x9a096c, 0x4c},
1177 {0x9a0904, 0x0},
1178 {0x9a096c, 0x4d},
1179 {0x9a0904, 0xffffffff},
1180 {0x9a096c, 0x4e},
1181 {0x9a0904, 0x0},
1182 {0x9a096c, 0x4f},
1183 {0x9a0904, 0xffffffff},
1184 {0x9a096c, 0x50},
1185 {0x9a0904, 0x55555555},
1186 {0x9a096c, 0x51},
1187 {0x9a0904, 0xaaaaaaaa},
1188 {0x9a096c, 0x52},
1189 {0x9a0904, 0x55555555},
1190 {0x9a096c, 0x53},
1191 {0x9a0904, 0xaaaaaaaa},
1192 {0x9a096c, 0x54},
1193 {0x9a0904, 0x55555555},
1194 {0x9a096c, 0x55},
1195 {0x9a0904, 0xaaaaaaaa},
1196 {0x9a096c, 0x56},
1197 {0x9a0904, 0x55555555},
1198 {0x9a096c, 0x57},
1199 {0x9a0904, 0xaaaaaaaa},
1200 {0x9a096c, 0x58},
1201 {0x9a0904, 0x55555555},
1202 {0x9a096c, 0x59},
1203 {0x9a0904, 0xaaaaaaaa},
1204 {0x9a096c, 0x5a},
1205 {0x9a0904, 0x55555555},
1206 {0x9a096c, 0x5b},
1207 {0x9a0904, 0xaaaaaaaa},
1208 {0x9a096c, 0x5c},
1209 {0x9a0904, 0x55555555},
1210 {0x9a096c, 0x5d},
1211 {0x9a0904, 0xaaaaaaaa},
1212 {0x9a096c, 0x5e},
1213 {0x9a0904, 0x55555555},
1214 {0x9a096c, 0x5f},
1215 {0x9a0904, 0x0},
1216 {0x9a096c, 0x60},
1217 {0x9a0904, 0xffffffff},
1218 {0x9a096c, 0x61},
1219 {0x9a0904, 0x0},
1220 {0x9a096c, 0x62},
1221 {0x9a0904, 0xffffffff},
1222 {0x9a096c, 0x63},
1223 {0x9a0904, 0x0},
1224 {0x9a096c, 0x64},
1225 {0x9a0904, 0xffffffff},
1226 {0x9a096c, 0x65},
1227 {0x9a0904, 0x0},
1228 {0x9a096c, 0x66},
1229 {0x9a0904, 0xffffffff},
1230 {0x9a096c, 0x67},
1231 {0x9a0904, 0x0},
1232 {0x9a096c, 0x68},
1233 {0x9a0904, 0xffffffff},
1234 {0x9a096c, 0x69},
1235 {0x9a0904, 0x0},
1236 {0x9a096c, 0x6a},
1237 {0x9a0904, 0xffffffff},
1238 {0x9a096c, 0x6b},
1239 {0x9a0904, 0x0},
1240 {0x9a096c, 0x6c},
1241 {0x9a0904, 0xffffffff},
1242 {0x9a096c, 0x6d},
1243 {0x9a0904, 0x0},
1244 {0x9a096c, 0x6e},
1245 {0x9a0904, 0xffffffff},
1246 {0x9a096c, 0x6f},
1247 {0x9a0904, 0x55555555},
1248 {0x9a096c, 0x70},
1249 {0x9a0904, 0xaaaaaaaa},
1250 {0x9a096c, 0x71},
1251 {0x9a0904, 0x55555555},
1252 {0x9a096c, 0x72},
1253 {0x9a0904, 0xaaaaaaaa},
1254 {0x9a096c, 0x73},
1255 {0x9a0904, 0x55555555},
1256 {0x9a096c, 0x74},
1257 {0x9a0904, 0xaaaaaaaa},
1258 {0x9a096c, 0x75},
1259 {0x9a0904, 0x55555555},
1260 {0x9a096c, 0x76},
1261 {0x9a0904, 0xaaaaaaaa},
1262 {0x9a096c, 0x77},
1263 {0x9a0904, 0x55555555},
1264 {0x9a096c, 0x78},
1265 {0x9a0904, 0xaaaaaaaa},
1266 {0x9a096c, 0x79},
1267 {0x9a0904, 0x55555555},
1268 {0x9a096c, 0x7a},
1269 {0x9a0904, 0xaaaaaaaa},
1270 {0x9a096c, 0x7b},
1271 {0x9a0904, 0x55555555},
1272 {0x9a096c, 0x7c},
1273 {0x9a0904, 0xaaaaaaaa},
1274 {0x9a096c, 0x7d},
1275 {0x9a0904, 0x55555555},
1276 {0x9a096c, 0x7e},
1277 {0x9a0904, 0xaaaaaaaa},
1278 {0x9a096c, 0x7f},
1279 {0x9a0904, 0xffff},
1280 {0x9a096c, 0x80},
1281 {0x9a0904, 0xffff0000},
1282 {0x9a096c, 0x81},
1283 {0x9a0904, 0xffff},
1284 {0x9a096c, 0x82},
1285 {0x9a0904, 0xffff0000},
1286 {0x9a096c, 0x83},
1287 {0x9a0904, 0xffff},
1288 {0x9a096c, 0x84},
1289 {0x9a0904, 0xffff0000},
1290 {0x9a096c, 0x85},
1291 {0x9a0904, 0xffff},
1292 {0x9a096c, 0x86},
1293 {0x9a0904, 0xffff0000},
1294 {0x9a096c, 0x87},
1295 {0x9a0904, 0xffff},
1296 {0x9a096c, 0x88},
1297 {0x9a0904, 0xffff0000},
1298 {0x9a096c, 0x89},
1299 {0x9a0904, 0xffff},
1300 {0x9a096c, 0x8a},
1301 {0x9a0904, 0xffff0000},
1302 {0x9a096c, 0x8b},
1303 {0x9a0904, 0xffff},
1304 {0x9a096c, 0x8c},
1305 {0x9a0904, 0xffff0000},
1306 {0x9a096c, 0x8d},
1307 {0x9a0904, 0xffff},
1308 {0x9a096c, 0x8e},
1309 {0x9a0904, 0xffff0000},
1310 {0x9a096c, 0x8f},
1311 {0x9a0904, 0xff00ff},
1312 {0x9a096c, 0x90},
1313 {0x9a0904, 0xff00ff00},
1314 {0x9a096c, 0x91},
1315 {0x9a0904, 0xff00ff},
1316 {0x9a096c, 0x92},
1317 {0x9a0904, 0xff00ff00},
1318 {0x9a096c, 0x93},
1319 {0x9a0904, 0xff00ff},
1320 {0x9a096c, 0x94},
1321 {0x9a0904, 0xff00ff00},
1322 {0x9a096c, 0x95},
1323 {0x9a0904, 0xff00ff},
1324 {0x9a096c, 0x96},
1325 {0x9a0904, 0xff00ff00},
1326 {0x9a096c, 0x97},
1327 {0x9a0904, 0xff00ff},
1328 {0x9a096c, 0x98},
1329 {0x9a0904, 0xff00ff00},
1330 {0x9a096c, 0x99},
1331 {0x9a0904, 0xff00ff},
1332 {0x9a096c, 0x9a},
1333 {0x9a0904, 0xff00ff00},
1334 {0x9a096c, 0x9b},
1335 {0x9a0904, 0xff00ff},
1336 {0x9a096c, 0x9c},
1337 {0x9a0904, 0xff00ff00},
1338 {0x9a096c, 0x9d},
1339 {0x9a0904, 0xff00ff},
1340 {0x9a096c, 0x9e},
1341 {0x9a0904, 0xff00ff00},
1342 {0x9a096c, 0x9f},
1343 {0x9a0904, 0x0},
1344 {0x9a096c, 0xa0},
1345 {0x9a0904, 0xffffffff},
1346 {0x9a096c, 0xa1},
1347 {0x9a0904, 0x0},
1348 {0x9a096c, 0xa2},
1349 {0x9a0904, 0xffffffff},
1350 {0x9a096c, 0xa3},
1351 {0x9a0904, 0x0},
1352 {0x9a096c, 0xa4},
1353 {0x9a0904, 0xffffffff},
1354 {0x9a096c, 0xa5},
1355 {0x9a0904, 0x0},
1356 {0x9a096c, 0xa6},
1357 {0x9a0904, 0xffffffff},
1358 {0x9a096c, 0xa7},
1359 {0x9a0904, 0x0},
1360 {0x9a096c, 0xa8},
1361 {0x9a0904, 0xffffffff},
1362 {0x9a096c, 0xa9},
1363 {0x9a0904, 0x0},
1364 {0x9a096c, 0xaa},
1365 {0x9a0904, 0xffffffff},
1366 {0x9a096c, 0xab},
1367 {0x9a0904, 0x0},
1368 {0x9a096c, 0xac},
1369 {0x9a0904, 0xffffffff},
1370 {0x9a096c, 0xad},
1371 {0x9a0904, 0x0},
1372 {0x9a096c, 0xae},
1373 {0x9a0904, 0xffffffff},
1374 {0x9a096c, 0xaf},
1375 {0x9a0904, 0x55555555},
1376 {0x9a096c, 0xb0},
1377 {0x9a0904, 0xaaaaaaaa},
1378 {0x9a096c, 0xb1},
1379 {0x9a0904, 0x55555555},
1380 {0x9a096c, 0xb2},
1381 {0x9a0904, 0xaaaaaaaa},
1382 {0x9a096c, 0xb3},
1383 {0x9a0904, 0x55555555},
1384 {0x9a096c, 0xb4},
1385 {0x9a0904, 0xaaaaaaaa},
1386 {0x9a096c, 0xb5},
1387 {0x9a0904, 0x55555555},
1388 {0x9a096c, 0xb6},
1389 {0x9a0904, 0xaaaaaaaa},
1390 {0x9a096c, 0xb7},
1391 {0x9a0904, 0x55555555},
1392 {0x9a096c, 0xb8},
1393 {0x9a0904, 0xaaaaaaaa},
1394 {0x9a096c, 0xb9},
1395 {0x9a0904, 0x55555555},
1396 {0x9a096c, 0xba},
1397 {0x9a0904, 0xaaaaaaaa},
1398 {0x9a096c, 0xbb},
1399 {0x9a0904, 0x55555555},
1400 {0x9a096c, 0xbc},
1401 {0x9a0904, 0xaaaaaaaa},
1402 {0x9a096c, 0xbd},
1403 {0x9a0904, 0x55555555},
1404 {0x9a096c, 0xbe},
1405 {0x9a0904, 0x0},
1406 {0x9a096c, 0xbf},
1407 {0x9a0904, 0xffffffff},
1408 {0x9a096c, 0xc0},
1409 {0x9a0904, 0x0},
1410 {0x9a096c, 0xc1},
1411 {0x9a0904, 0xffffffff},
1412 {0x9a096c, 0xc2},
1413 {0x9a0904, 0x0},
1414 {0x9a096c, 0xc3},
1415 {0x9a0904, 0xffffffff},
1416 {0x9a096c, 0xc4},
1417 {0x9a0904, 0x0},
1418 {0x9a096c, 0xc5},
1419 {0x9a0904, 0xffffffff},
1420 {0x9a096c, 0xc6},
1421 {0x9a0904, 0x0},
1422 {0x9a096c, 0xc7},
1423 {0x9a0904, 0xffffffff},
1424 {0x9a096c, 0xc8},
1425 {0x9a0904, 0x0},
1426 {0x9a096c, 0xc9},
1427 {0x9a0904, 0xffffffff},
1428 {0x9a096c, 0xca},
1429 {0x9a0904, 0x0},
1430 {0x9a096c, 0xcb},
1431 {0x9a0904, 0xffffffff},
1432 {0x9a096c, 0xcc},
1433 {0x9a0904, 0x0},
1434 {0x9a096c, 0xcd},
1435 {0x9a0904, 0xffffffff},
1436 {0x9a096c, 0xce},
1437 {0x9a0904, 0x55555555},
1438 {0x9a096c, 0xcf},
1439 {0x9a0904, 0xaaaaaaaa},
1440 {0x9a096c, 0xd0},
1441 {0x9a0904, 0x55555555},
1442 {0x9a096c, 0xd1},
1443 {0x9a0904, 0xaaaaaaaa},
1444 {0x9a096c, 0xd2},
1445 {0x9a0904, 0x55555555},
1446 {0x9a096c, 0xd3},
1447 {0x9a0904, 0xaaaaaaaa},
1448 {0x9a096c, 0xd4},
1449 {0x9a0904, 0x55555555},
1450 {0x9a096c, 0xd5},
1451 {0x9a0904, 0xaaaaaaaa},
1452 {0x9a096c, 0xd6},
1453 {0x9a0904, 0x55555555},
1454 {0x9a096c, 0xd7},
1455 {0x9a0904, 0xaaaaaaaa},
1456 {0x9a096c, 0xd8},
1457 {0x9a0904, 0x55555555},
1458 {0x9a096c, 0xd9},
1459 {0x9a0904, 0xaaaaaaaa},
1460 {0x9a096c, 0xda},
1461 {0x9a0904, 0x55555555},
1462 {0x9a096c, 0xdb},
1463 {0x9a0904, 0xaaaaaaaa},
1464 {0x9a096c, 0xdc},
1465 {0x9a0904, 0x55555555},
1466 {0x9a096c, 0xdd},
1467 {0x9a0904, 0xaaaaaaaa},
1468 {0x9a096c, 0xde},
1469 {0x9a0904, 0xffff},
1470 {0x9a096c, 0xdf},
1471 {0x9a0904, 0xffff0000},
1472 {0x9a096c, 0xe0},
1473 {0x9a0904, 0xffff},
1474 {0x9a096c, 0xe1},
1475 {0x9a0904, 0xffff0000},
1476 {0x9a096c, 0xe2},
1477 {0x9a0904, 0xffff},
1478 {0x9a096c, 0xe3},
1479 {0x9a0904, 0xffff0000},
1480 {0x9a096c, 0xe4},
1481 {0x9a0904, 0xffff},
1482 {0x9a096c, 0xe5},
1483 {0x9a0904, 0xffff0000},
1484 {0x9a096c, 0xe6},
1485 {0x9a0904, 0xffff},
1486 {0x9a096c, 0xe7},
1487 {0x9a0904, 0xffff0000},
1488 {0x9a096c, 0xe8},
1489 {0x9a0904, 0xffff},
1490 {0x9a096c, 0xe9},
1491 {0x9a0904, 0xffff0000},
1492 {0x9a096c, 0xea},
1493 {0x9a0904, 0xffff},
1494 {0x9a096c, 0xeb},
1495 {0x9a0904, 0xffff0000},
1496 {0x9a096c, 0xec},
1497 {0x9a0904, 0xffff},
1498 {0x9a096c, 0xed},
1499 {0x9a0904, 0xffff0000},
1500 {0x9a096c, 0xee},
1501 {0x9a0904, 0xff00ff},
1502 {0x9a096c, 0xef},
1503 {0x9a0904, 0xff00ff00},
1504 {0x9a096c, 0xf0},
1505 {0x9a0904, 0xff00ff},
1506 {0x9a096c, 0xf1},
1507 {0x9a0904, 0xff00ff00},
1508 {0x9a096c, 0xf2},
1509 {0x9a0904, 0xff00ff},
1510 {0x9a096c, 0xf3},
1511 {0x9a0904, 0xff00ff00},
1512 {0x9a096c, 0xf4},
1513 {0x9a0904, 0xff00ff},
1514 {0x9a096c, 0xf5},
1515 {0x9a0904, 0xff00ff00},
1516 {0x9a096c, 0xf6},
1517 {0x9a0904, 0xff00ff},
1518 {0x9a096c, 0xf7},
1519 {0x9a0904, 0xff00ff00},
1520 {0x9a096c, 0xf8},
1521 {0x9a0904, 0xff00ff},
1522 {0x9a096c, 0xf9},
1523 {0x9a0904, 0xff00ff00},
1524 {0x9a096c, 0xfa},
1525 {0x9a0904, 0xff00ff},
1526 {0x9a096c, 0xfb},
1527 {0x9a0904, 0xff00ff00},
1528 {0x9a096c, 0xfc},
1529 {0x9a0904, 0xff00ff},
1530 {0x9a096c, 0xfd},
1531 {0x9a0904, 0xff00ff00},
1532 {0x9a096c, 0xfe},
1533 {0x9a0904, 0x0},
1534 {0x9a096c, 0xff},
1535 {0x9a0904, 0xffffffff},
1536};
1537
1538/* MID SPEED TO LOW SPEED */
1539static u8 seq_script_step33_ls_gp106[] = {
1540 0x34, 0x00, 0x02, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x20, 0x00, 0x03, 0x00, 0x01,
1541 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00, 0x00, 0x02,
1542 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x02, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0C,
1543 0x00, 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x49, 0x90, 0x00,
1544 0x00, 0x00, 0x0C, 0x00, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x10,
1545 0x02, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03,
1546 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x10, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00,
1547 0x00, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00,
1548 0x48, 0x03, 0x9A, 0x00, 0x88, 0x00, 0x70, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00,
1549 0x90, 0x8F, 0x82, 0x14, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02,
1550 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x02, 0x90, 0x00, 0x9A, 0x00, 0x61, 0x00, 0x00,
1551 0x00, 0x90, 0x00, 0x9A, 0x00, 0x7F, 0x00, 0x00, 0xC0, 0x2E, 0x00, 0x02, 0x00,
1552 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x27, 0x00, 0x98, 0x06, 0x9A, 0x00, 0x00,
1553 0x00, 0x00, 0x00, 0x9C, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x08,
1554 0x9A, 0x00, 0xE7, 0x8F, 0x83, 0x40, 0x38, 0x1F, 0x9A, 0x00, 0x00, 0x00, 0x01,
1555 0x00, 0x34, 0x1F, 0x9A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x34, 0x0D, 0x9A, 0x00,
1556 0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x8B, 0xC0, 0x24,
1557 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x83, 0x40, 0xF4, 0x73, 0x13, 0x00, 0x11, 0x00,
1558 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x10, 0x00, 0x01, 0x00, 0xF4, 0x73, 0x13,
1559 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x13, 0x00, 0x00, 0x00, 0x01, 0x18,
1560 0x00, 0x20, 0x13, 0x00, 0x02, 0x00, 0x01, 0x18, 0x20, 0x20, 0x13, 0x00, 0x00,
1561 0x00, 0x03, 0x20, 0x20, 0x73, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x20,
1562 0x13, 0x00, 0x01, 0x3B, 0x04, 0x00, 0x2C, 0x20, 0x13, 0x00, 0x00, 0x01, 0x00,
1563 0x00, 0x28, 0x20, 0x13, 0x00, 0x10, 0x00, 0x08, 0x10, 0x20, 0x20, 0x13, 0x00,
1564 0x01, 0x00, 0x03, 0x20, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,
1565 0x00, 0x02, 0x00, 0x90, 0x73, 0x13, 0x00, 0x15, 0x00, 0x03, 0x00, 0x00, 0x00,
1566 0x02, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x21, 0x00, 0x1F, 0x00, 0x2C, 0x20, 0x13,
1567 0x00, 0x00, 0x03, 0x00, 0x00, 0x28, 0x20, 0x13, 0x00, 0x10, 0x00, 0x04, 0x10,
1568 0xF4, 0x73, 0x13, 0x00, 0x00, 0x01, 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x10,
1569 0x01, 0x01, 0x00, 0xEC, 0x73, 0x13, 0x00, 0x00, 0x00, 0x01, 0x00, 0xF4, 0x73,
1570 0x13, 0x00, 0x11, 0x01, 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x11, 0x01, 0x00,
1571 0x00, 0x5C, 0x06, 0x9A, 0x00, 0x11, 0x00, 0x00, 0x00, 0x70, 0x06, 0x9A, 0x00,
1572 0x06, 0x13, 0x08, 0xB4, 0x98, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C,
1573 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94, 0x06, 0x9A, 0x00, 0x0E, 0x06,
1574 0x0E, 0x06, 0xD4, 0x0E, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x40, 0xD4, 0x0E, 0x9A,
1575 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x80, 0x40,
1576 0x13, 0x00, 0x02, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0x10,
1577 0x27, 0x00, 0x00, 0x21, 0x00, 0x1D, 0x00, 0x70, 0x06, 0x9A, 0x00, 0x06, 0x13,
1578 0x08, 0x34, 0x48, 0x02, 0x9A, 0x00, 0xA3, 0x44, 0x14, 0x86, 0x90, 0x02, 0x9A,
1579 0x00, 0x12, 0x2C, 0x18, 0x06, 0x94, 0x02, 0x9A, 0x00, 0x8A, 0x82, 0x41, 0x24,
1580 0x98, 0x02, 0x9A, 0x00, 0x11, 0x05, 0x06, 0x88, 0x9C, 0x02, 0x9A, 0x00, 0x8C,
1581 0x10, 0x00, 0x22, 0xA8, 0x02, 0x9A, 0x00, 0x0B, 0x86, 0x00, 0x01, 0x4C, 0x02,
1582 0x9A, 0x00, 0x85, 0x0C, 0x05, 0x06, 0x30, 0x1F, 0x9A, 0x00, 0x03, 0x16, 0x2C,
1583 0x00, 0xE0, 0x08, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x03, 0x9A, 0x00,
1584 0x00, 0x00, 0x00, 0x00, 0x94, 0x03, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1585 0x0B, 0x9A, 0x00, 0x06, 0x22, 0x22, 0x22, 0x90, 0x00, 0x9A, 0x00, 0x7E, 0x00,
1586 0x00, 0x40, 0x2E, 0x00, 0x02, 0x00, 0xD0, 0x07, 0x00, 0x00, 0x21, 0x00, 0x0D,
1587 0x00, 0x14, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x03, 0x9A, 0x00,
1588 0x01, 0x00, 0x00, 0x00, 0x10, 0x02, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x80, 0x90,
1589 0x03, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x03, 0x9A, 0x00, 0x23, 0x01,
1590 0x30, 0x00, 0x00, 0x03, 0x9A, 0x00, 0x2D, 0x02, 0x00, 0x00, 0x2E, 0x00, 0x02,
1591 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x07, 0x00, 0x00, 0x02, 0x9A, 0x00,
1592 0x00, 0x90, 0x8F, 0x82, 0x18, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
1593 0x02, 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x02, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03,
1594 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00, 0x78, 0x09, 0x9A, 0x00, 0x0B, 0x1E, 0x7A,
1595 0x88, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10, 0x27, 0x00, 0x10, 0x09, 0x90, 0x00,
1596 0x00, 0x00, 0x0A, 0x98, 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0A, 0x98, 0x10,
1597 0x49, 0x90, 0x00, 0x00, 0x00, 0x0A, 0x98, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00,
1598 0x0A, 0x98, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,
1599 0x00, 0x74, 0x09, 0x90, 0x00, 0x15, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00, 0x00,
1600 0x20, 0xA1, 0x07, 0x00, 0x01, 0x00, 0x02, 0x00, 0x74, 0x49, 0x90, 0x00, 0x15,
1601 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x20, 0xA1, 0x07, 0x00, 0x21, 0x00,
1602 0x0D, 0x00, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10, 0x27, 0x01, 0x30, 0x08, 0x9A,
1603 0x00, 0x91, 0x10, 0x27, 0x00, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x08, 0x19,
1604 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x08, 0x19, 0x10, 0x49, 0x90, 0x00, 0x00,
1605 0x00, 0x08, 0x19, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00, 0x08, 0x19, 0x20, 0x00,
1606 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x02,
1607 0x00, 0x0B, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x00, 0x02, 0x9A, 0x00,
1608 0x00, 0x98, 0x8F, 0x02, 0x16, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
1609};
1610
1611/* LOW SPEED TO MID SPEED */
1612static u8 seq_script_step33_gp106[] = {
1613 0x34, 0x00, 0x02, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x20, 0x00, 0x03, 0x00, 0x01,
1614 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00, 0x00, 0x02,
1615 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x02, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0C,
1616 0x00, 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x49, 0x90, 0x00,
1617 0x00, 0x00, 0x0C, 0x00, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x10,
1618 0x02, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03,
1619 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x10, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00,
1620 0x00, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00,
1621 0x48, 0x03, 0x9A, 0x00, 0x88, 0x00, 0x70, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00,
1622 0x90, 0x8F, 0x82, 0x14, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02,
1623 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x02, 0x90, 0x00, 0x9A, 0x00, 0x61, 0x00, 0x00,
1624 0x00, 0x90, 0x00, 0x9A, 0x00, 0x7F, 0x00, 0x00, 0xC0, 0x2E, 0x00, 0x02, 0x00,
1625 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x27, 0x00, 0x98, 0x06, 0x9A, 0x00, 0x00,
1626 0x00, 0x00, 0x00, 0x9C, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x08,
1627 0x9A, 0x00, 0xE7, 0x8F, 0x83, 0x40, 0x38, 0x1F, 0x9A, 0x00, 0x00, 0x00, 0x01,
1628 0x00, 0x34, 0x1F, 0x9A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x34, 0x0D, 0x9A, 0x00,
1629 0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x8B, 0xC0, 0x24,
1630 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x83, 0x40, 0xF4, 0x73, 0x13, 0x00, 0x11, 0x00,
1631 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x10, 0x00, 0x01, 0x00, 0xF4, 0x73, 0x13,
1632 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x20, 0x13, 0x00, 0x00, 0x00, 0x01, 0x18,
1633 0x00, 0x20, 0x13, 0x00, 0x02, 0x00, 0x01, 0x18, 0x20, 0x20, 0x13, 0x00, 0x00,
1634 0x00, 0x03, 0x20, 0x20, 0x73, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x20,
1635 0x13, 0x00, 0x01, 0x3B, 0x02, 0x00, 0x2C, 0x20, 0x13, 0x00, 0x00, 0x01, 0x00,
1636 0x00, 0x28, 0x20, 0x13, 0x00, 0x10, 0x00, 0x08, 0x10, 0x20, 0x20, 0x13, 0x00,
1637 0x01, 0x00, 0x03, 0x20, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,
1638 0x00, 0x02, 0x00, 0x90, 0x73, 0x13, 0x00, 0x15, 0x00, 0x03, 0x00, 0x00, 0x00,
1639 0x02, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x21, 0x00, 0x1F, 0x00, 0x2C, 0x20, 0x13,
1640 0x00, 0x00, 0x03, 0x00, 0x00, 0x28, 0x20, 0x13, 0x00, 0x10, 0x00, 0x04, 0x10,
1641 0xF4, 0x73, 0x13, 0x00, 0x00, 0x01, 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x10,
1642 0x01, 0x01, 0x00, 0xEC, 0x73, 0x13, 0x00, 0x00, 0x00, 0x01, 0x00, 0xF4, 0x73,
1643 0x13, 0x00, 0x11, 0x01, 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x11, 0x01, 0x00,
1644 0x00, 0x5C, 0x06, 0x9A, 0x00, 0x11, 0x00, 0x00, 0x00, 0x70, 0x06, 0x9A, 0x00,
1645 0x06, 0x13, 0x08, 0xB4, 0x98, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C,
1646 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94, 0x06, 0x9A, 0x00, 0x0E, 0x06,
1647 0x0E, 0x06, 0xD4, 0x0E, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x40, 0xD4, 0x0E, 0x9A,
1648 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x80, 0x40,
1649 0x13, 0x00, 0x02, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0x10,
1650 0x27, 0x00, 0x00, 0x21, 0x00, 0x1D, 0x00, 0x70, 0x06, 0x9A, 0x00, 0x06, 0x13,
1651 0x08, 0x34, 0x48, 0x02, 0x9A, 0x00, 0xA3, 0x44, 0x14, 0x86, 0x90, 0x02, 0x9A,
1652 0x00, 0x12, 0x2C, 0x18, 0x06, 0x94, 0x02, 0x9A, 0x00, 0x8A, 0x82, 0x41, 0x24,
1653 0x98, 0x02, 0x9A, 0x00, 0x11, 0x05, 0x06, 0x88, 0x9C, 0x02, 0x9A, 0x00, 0x8C,
1654 0x10, 0x00, 0x22, 0xA8, 0x02, 0x9A, 0x00, 0x0B, 0x86, 0x00, 0x01, 0x4C, 0x02,
1655 0x9A, 0x00, 0x85, 0x0C, 0x05, 0x06, 0x30, 0x1F, 0x9A, 0x00, 0x03, 0x16, 0x2C,
1656 0x00, 0xE0, 0x08, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x03, 0x9A, 0x00,
1657 0x00, 0x00, 0x00, 0x00, 0x94, 0x03, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1658 0x0B, 0x9A, 0x00, 0x06, 0x22, 0x22, 0x22, 0x90, 0x00, 0x9A, 0x00, 0x7E, 0x00,
1659 0x00, 0x40, 0x2E, 0x00, 0x02, 0x00, 0xD0, 0x07, 0x00, 0x00, 0x21, 0x00, 0x0D,
1660 0x00, 0x14, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x03, 0x9A, 0x00,
1661 0x01, 0x00, 0x00, 0x00, 0x10, 0x02, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x80, 0x90,
1662 0x03, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x03, 0x9A, 0x00, 0x23, 0x01,
1663 0x30, 0x00, 0x00, 0x03, 0x9A, 0x00, 0x2D, 0x02, 0x00, 0x00, 0x2E, 0x00, 0x02,
1664 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x07, 0x00, 0x00, 0x02, 0x9A, 0x00,
1665 0x00, 0x90, 0x8F, 0x82, 0x18, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
1666 0x02, 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x02, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03,
1667 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00, 0x78, 0x09, 0x9A, 0x00, 0x0B, 0x1E, 0x7A,
1668 0x88, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10, 0x27, 0x00, 0x10, 0x09, 0x90, 0x00,
1669 0x00, 0x00, 0x0A, 0x98, 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0A, 0x98, 0x10,
1670 0x49, 0x90, 0x00, 0x00, 0x00, 0x0A, 0x98, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00,
1671 0x0A, 0x98, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,
1672 0x00, 0x74, 0x09, 0x90, 0x00, 0x15, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00, 0x00,
1673 0x20, 0xA1, 0x07, 0x00, 0x01, 0x00, 0x02, 0x00, 0x74, 0x49, 0x90, 0x00, 0x15,
1674 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x20, 0xA1, 0x07, 0x00, 0x21, 0x00,
1675 0x0D, 0x00, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10, 0x27, 0x01, 0x30, 0x08, 0x9A,
1676 0x00, 0x91, 0x10, 0x27, 0x00, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x08, 0x19,
1677 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x08, 0x19, 0x10, 0x49, 0x90, 0x00, 0x00,
1678 0x00, 0x08, 0x19, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00, 0x08, 0x19, 0x20, 0x00,
1679 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x02,
1680 0x00, 0x0B, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x00, 0x02, 0x9A, 0x00,
1681 0x00, 0x98, 0x8F, 0x02, 0x16, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
1682};
1683
1684/* LOW/MID SPEED TO HIGH SPEED */
1685static u8 seq_script_step28_gp106[] = {
1686 0x34, 0x00, 0x02, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x20, 0x00, 0x03, 0x00, 0x01,
1687 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x07, 0x00, 0x30, 0x03,
1688 0x9A, 0x00, 0x14, 0x00, 0x10, 0x00, 0x38, 0xD6, 0x00, 0x00, 0x00, 0x60, 0x00,
1689 0x00, 0x04, 0xD6, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00,
1690 0x20, 0x4E, 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00,
1691 0x90, 0x8F, 0x02, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x14, 0x09,
1692 0x90, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0C,
1693 0x00, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x10, 0x02, 0x9A, 0x00,
1694 0x00, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21,
1695 0x00, 0x03, 0x00, 0x10, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2E, 0x00,
1696 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00, 0x48, 0x03, 0x9A,
1697 0x00, 0x88, 0x00, 0x70, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x82,
1698 0x14, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00,
1699 0x90, 0x8F, 0x02, 0x90, 0x00, 0x9A, 0x00, 0x61, 0x00, 0x00, 0x00, 0x90, 0x00,
1700 0x9A, 0x00, 0x7F, 0x00, 0x00, 0xC0, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00,
1701 0x00, 0x21, 0x00, 0x27, 0x00, 0x98, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00,
1702 0x9C, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00, 0xE7,
1703 0x8F, 0x88, 0xF7, 0x40, 0x0D, 0x9A, 0x00, 0x20, 0xE0, 0x01, 0x00, 0x00, 0x02,
1704 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x1A, 0x00, 0x08, 0x9A, 0x00, 0x00, 0x00, 0x00,
1705 0x00, 0xF0, 0x73, 0x13, 0x00, 0x03, 0x00, 0x00, 0x00, 0x30, 0x08, 0x9A, 0x00,
1706 0x90, 0x90, 0x67, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x11, 0x00, 0x01, 0x00, 0xF4,
1707 0x73, 0x13, 0x00, 0x10, 0x00, 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x00, 0x00,
1708 0x01, 0x00, 0x20, 0x20, 0x13, 0x00, 0x00, 0x00, 0x03, 0x20, 0x20, 0x73, 0x13,
1709 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20, 0x13, 0x00, 0x04, 0x00, 0x00, 0x00,
1710 0x34, 0x20, 0x13, 0x00, 0x00, 0x00, 0x8A, 0xF9, 0x24, 0x20, 0x13, 0x00, 0x01,
1711 0x32, 0x05, 0x00, 0x2C, 0x20, 0x13, 0x00, 0x00, 0x01, 0x00, 0x00, 0x28, 0x20,
1712 0x13, 0x00, 0x10, 0x00, 0x08, 0x10, 0x20, 0x20, 0x13, 0x00, 0x01, 0x00, 0x03,
1713 0x20, 0x34, 0x00, 0x02, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
1714 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x90, 0x73, 0x13, 0x00, 0x15,
1715 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0xFA, 0x00, 0x00, 0x34, 0x00,
1716 0x02, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00, 0x2C, 0x20, 0x13,
1717 0x00, 0x00, 0x03, 0x00, 0x00, 0x28, 0x20, 0x13, 0x00, 0x10, 0x00, 0x04, 0x10,
1718 0xF4, 0x73, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x13, 0x00, 0x00,
1719 0x00, 0x01, 0x98, 0x04, 0x20, 0x13, 0x00, 0x01, 0x0B, 0x01, 0x00, 0x00, 0x20,
1720 0x13, 0x00, 0x01, 0x00, 0x01, 0x98, 0x34, 0x00, 0x02, 0x00, 0x0D, 0x00, 0x00,
1721 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
1722 0x90, 0x73, 0x13, 0x00, 0x15, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
1723 0xFA, 0x00, 0x00, 0x34, 0x00, 0x02, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x21, 0x00,
1724 0x1D, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x00, 0x11, 0x00, 0x00, 0xF4, 0x73, 0x13,
1725 0x00, 0x10, 0x11, 0x00, 0x00, 0xEC, 0x73, 0x13, 0x00, 0x00, 0x00, 0x03, 0x00,
1726 0xF0, 0x73, 0x13, 0x00, 0x02, 0x00, 0x00, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x12,
1727 0x11, 0x00, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x12, 0x00, 0x00, 0x00, 0x08, 0x08,
1728 0x9A, 0x00, 0x70, 0x00, 0x08, 0x48, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x10, 0x8F,
1729 0x1A, 0x24, 0x08, 0x9A, 0x00, 0xE5, 0x8F, 0x88, 0xF7, 0x08, 0x08, 0x9A, 0x00,
1730 0x70, 0x00, 0xA8, 0x4A, 0x24, 0x08, 0x9A, 0x00, 0x85, 0x8F, 0x88, 0xF7, 0x38,
1731 0x1F, 0x9A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x34, 0x1F, 0x9A, 0x00, 0x00, 0x00,
1732 0x01, 0x00, 0x34, 0x0D, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02,
1733 0x00, 0x2C, 0x01, 0x00, 0x00, 0x21, 0x00, 0x09, 0x00, 0x5C, 0x06, 0x9A, 0x00,
1734 0x22, 0x00, 0x00, 0x00, 0x0C, 0x06, 0x9A, 0x00, 0xD0, 0x20, 0x00, 0xFD, 0xD4,
1735 0x0E, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x40, 0xD4, 0x0E, 0x9A, 0x00, 0x00, 0x00,
1736 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x21, 0x00, 0x25,
1737 0x00, 0x2C, 0x08, 0x9A, 0x00, 0x00, 0x00, 0x05, 0x00, 0x30, 0x08, 0x9A, 0x00,
1738 0x90, 0xA0, 0x67, 0x00, 0x48, 0x02, 0x9A, 0x00, 0xA3, 0x44, 0x20, 0x95, 0x90,
1739 0x02, 0x9A, 0x00, 0x46, 0xAE, 0x60, 0x16, 0x94, 0x02, 0x9A, 0x00, 0x96, 0x02,
1740 0xF6, 0x28, 0x98, 0x02, 0x9A, 0x00, 0x00, 0x09, 0x16, 0x88, 0x9C, 0x02, 0x9A,
1741 0x00, 0x4C, 0x39, 0x00, 0x24, 0xA0, 0x02, 0x9A, 0x00, 0x32, 0x80, 0x83, 0xD5,
1742 0xA8, 0x02, 0x9A, 0x00, 0x0F, 0x86, 0x00, 0x02, 0x14, 0x06, 0x9A, 0x00, 0x77,
1743 0x4E, 0x04, 0x40, 0x10, 0x06, 0x9A, 0x00, 0x77, 0x4E, 0x04, 0x40, 0x78, 0x07,
1744 0x10, 0x00, 0x44, 0x04, 0x00, 0x82, 0x4C, 0x02, 0x9A, 0x00, 0x85, 0x0C, 0x05,
1745 0x15, 0xE0, 0x08, 0x9A, 0x00, 0x11, 0x00, 0x00, 0x00, 0x90, 0x03, 0x9A, 0x00,
1746 0x00, 0x00, 0x00, 0x00, 0x94, 0x03, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1747 0x0B, 0x9A, 0x00, 0x06, 0x22, 0x22, 0x22, 0x90, 0x00, 0x9A, 0x00, 0x7E, 0x00,
1748 0x00, 0x40, 0x2E, 0x00, 0x02, 0x00, 0xD0, 0x07, 0x00, 0x00, 0x21, 0x00, 0x13,
1749 0x00, 0x14, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x03, 0x9A, 0x00,
1750 0x01, 0x00, 0x00, 0x00, 0x10, 0x02, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x80, 0x90,
1751 0x03, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94, 0x02, 0x9A, 0x00, 0x96, 0x02,
1752 0xF6, 0x24, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x01, 0xA4, 0x14, 0x09, 0x90,
1753 0x00, 0x00, 0x00, 0x01, 0xA4, 0x10, 0x49, 0x90, 0x00, 0x00, 0x00, 0x01, 0xA4,
1754 0x14, 0x49, 0x90, 0x00, 0x00, 0x00, 0x01, 0xA4, 0x34, 0x00, 0x02, 0x00, 0x0F,
1755 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
1756 0x02, 0x00, 0x74, 0x09, 0x90, 0x00, 0x15, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00,
1757 0x00, 0x20, 0xA1, 0x07, 0x00, 0x01, 0x00, 0x02, 0x00, 0x74, 0x49, 0x90, 0x00,
1758 0x15, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x20, 0xA1, 0x07, 0x00, 0x34,
1759 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03,
1760 0x00, 0x00, 0x21, 0x00, 0x0B, 0x00, 0x94, 0x02, 0x9A, 0x00, 0x96, 0x02, 0xF6,
1761 0x28, 0x38, 0x03, 0x9A, 0x00, 0x03, 0x01, 0x30, 0x00, 0x3C, 0x03, 0x9A, 0x00,
1762 0xFF, 0x01, 0x40, 0x00, 0x00, 0x03, 0x9A, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x54,
1763 0x03, 0x9A, 0x00, 0x03, 0x00, 0x80, 0x00, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03,
1764 0x00, 0x00, 0x21, 0x00, 0x09, 0x00, 0x48, 0x03, 0x9A, 0x00, 0x00, 0x00, 0x70,
1765 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x10, 0x8F, 0x9A, 0x18, 0x03, 0x9A, 0x00,
1766 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x10, 0x8F, 0x1A, 0x2E,
1767 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x0B, 0x00, 0x78, 0x09,
1768 0x9A, 0x00, 0x0F, 0x1E, 0x7E, 0x88, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0E,
1769 0xA4, 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0E, 0xA4, 0x10, 0x49, 0x90, 0x00,
1770 0x00, 0x00, 0x0E, 0xA4, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0E, 0xA4, 0x34,
1771 0x00, 0x02, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1772 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x74, 0x09, 0x90, 0x00, 0x15, 0x00, 0x03,
1773 0x00, 0x0F, 0x00, 0x00, 0x00, 0x20, 0xA1, 0x07, 0x00, 0x01, 0x00, 0x02, 0x00,
1774 0x74, 0x49, 0x90, 0x00, 0x15, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x20,
1775 0xA1, 0x07, 0x00, 0x34, 0x00, 0x02, 0x00, 0x12, 0x00, 0x00, 0x00, 0x2E, 0x00,
1776 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x0B, 0x00, 0x00, 0x02, 0x9A,
1777 0x00, 0x00, 0x10, 0x8F, 0x3A, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x25,
1778 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x25, 0x10, 0x49, 0x90, 0x00, 0x00,
1779 0x00, 0x0C, 0x25, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x25, 0x20, 0x00,
1780 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x02,
1781 0x00, 0x13, 0x00, 0x00, 0x00, 0x16, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
1782};
1783
1784/* HIGH SPEED TO LOW SPEED */
1785static u8 seq_script_step32_ls_gp106[] = {
1786 0x34, 0x00, 0x02, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x20, 0x00, 0x03, 0x00, 0x01,
1787 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x0B, 0x00, 0x10, 0x09,
1788 0x90, 0x00, 0x00, 0x00, 0x0C, 0x24, 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0C,
1789 0x24, 0x10, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x24, 0x14, 0x49, 0x90, 0x00,
1790 0x00, 0x00, 0x0C, 0x24, 0x10, 0x02, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E,
1791 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x10, 0x03,
1792 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00,
1793 0x00, 0x21, 0x00, 0x0D, 0x00, 0x48, 0x03, 0x9A, 0x00, 0x00, 0x00, 0x70, 0x00,
1794 0x00, 0x02, 0x9A, 0x00, 0x00, 0x10, 0x8F, 0x82, 0x14, 0x03, 0x9A, 0x00, 0x01,
1795 0x00, 0x00, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x10, 0x8F, 0x02, 0x90, 0x00,
1796 0x9A, 0x00, 0x61, 0x00, 0x00, 0x00, 0x90, 0x00, 0x9A, 0x00, 0x7F, 0x00, 0x00,
1797 0xC0, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x35, 0x00,
1798 0x98, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x06, 0x9A, 0x00, 0x00,
1799 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00, 0x85, 0x8F, 0x8B, 0xF7, 0x38, 0x1F,
1800 0x9A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x34, 0x1F, 0x9A, 0x00, 0x00, 0x00, 0x01,
1801 0x00, 0x34, 0x0D, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00,
1802 0xE7, 0x8F, 0x8B, 0xF7, 0x40, 0x0D, 0x9A, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x24,
1803 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x83, 0x40, 0x08, 0x08, 0x9A, 0x00, 0x70, 0x00,
1804 0xA0, 0x4A, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x02, 0x30, 0x08, 0x9A,
1805 0x00, 0x90, 0x20, 0x67, 0x01, 0x30, 0x08, 0x9A, 0x00, 0x90, 0x20, 0x67, 0x00,
1806 0xF4, 0x73, 0x13, 0x00, 0x12, 0x11, 0x00, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x10,
1807 0x11, 0x00, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x20,
1808 0x13, 0x00, 0x00, 0x00, 0x03, 0x98, 0x00, 0x20, 0x13, 0x00, 0x02, 0x00, 0x03,
1809 0x98, 0x20, 0x20, 0x13, 0x00, 0x00, 0x00, 0x03, 0x20, 0x20, 0x73, 0x13, 0x00,
1810 0x00, 0x00, 0x00, 0x00, 0x30, 0x20, 0x13, 0x00, 0x06, 0x00, 0x00, 0x10, 0x34,
1811 0x20, 0x13, 0x00, 0x00, 0x10, 0x67, 0x06, 0x24, 0x20, 0x13, 0x00, 0x01, 0x3B,
1812 0x04, 0x00, 0x2C, 0x20, 0x13, 0x00, 0x00, 0x01, 0x00, 0x00, 0x28, 0x20, 0x13,
1813 0x00, 0x10, 0x00, 0x08, 0x10, 0x20, 0x20, 0x13, 0x00, 0x01, 0x00, 0x03, 0x20,
1814 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x90,
1815 0x73, 0x13, 0x00, 0x15, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0xFA,
1816 0x00, 0x00, 0x21, 0x00, 0x23, 0x00, 0x2C, 0x20, 0x13, 0x00, 0x00, 0x03, 0x00,
1817 0x00, 0x28, 0x20, 0x13, 0x00, 0x10, 0x00, 0x04, 0x10, 0xF4, 0x73, 0x13, 0x00,
1818 0x00, 0x11, 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x10, 0x11, 0x01, 0x00, 0xF0,
1819 0x73, 0x13, 0x00, 0x01, 0x00, 0x00, 0x00, 0xEC, 0x73, 0x13, 0x00, 0x00, 0x00,
1820 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x11, 0x11, 0x01, 0x00, 0xF4, 0x73, 0x13,
1821 0x00, 0x11, 0x11, 0x00, 0x00, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x20, 0x27, 0x00,
1822 0x5C, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x98, 0x06, 0x9A, 0x00, 0x06,
1823 0x06, 0x06, 0x06, 0x9C, 0x06, 0x9A, 0x00, 0x06, 0x06, 0x06, 0x06, 0x94, 0x06,
1824 0x9A, 0x00, 0x0E, 0x06, 0x0E, 0x06, 0x0C, 0x06, 0x9A, 0x00, 0x50, 0x20, 0x00,
1825 0xFD, 0xD4, 0x0E, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x40, 0xD4, 0x0E, 0x9A, 0x00,
1826 0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x80, 0x40, 0x13,
1827 0x00, 0x02, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x21, 0x00, 0x23, 0x00, 0x2C, 0x08,
1828 0x9A, 0x00, 0x00, 0x00, 0x15, 0x00, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10, 0x27,
1829 0x00, 0x48, 0x02, 0x9A, 0x00, 0xA3, 0x44, 0x14, 0x84, 0x90, 0x02, 0x9A, 0x00,
1830 0x0A, 0x17, 0x0E, 0x03, 0x94, 0x02, 0x9A, 0x00, 0x89, 0x02, 0x21, 0x24, 0x98,
1831 0x02, 0x9A, 0x00, 0x11, 0x04, 0x05, 0x88, 0x9C, 0x02, 0x9A, 0x00, 0x6C, 0x10,
1832 0x00, 0x22, 0xA0, 0x02, 0x9A, 0x00, 0x32, 0x00, 0x61, 0xD3, 0xA8, 0x02, 0x9A,
1833 0x00, 0x0B, 0x86, 0x00, 0x02, 0x14, 0x06, 0x9A, 0x00, 0x77, 0x3E, 0x03, 0x30,
1834 0x10, 0x06, 0x9A, 0x00, 0x77, 0x3E, 0x03, 0x30, 0x08, 0x08, 0x9A, 0x00, 0x70,
1835 0x00, 0x00, 0x48, 0x78, 0x07, 0x10, 0x00, 0x33, 0x03, 0x00, 0x82, 0x4C, 0x02,
1836 0x9A, 0x00, 0x85, 0x0C, 0x05, 0x04, 0x30, 0x1F, 0x9A, 0x00, 0x03, 0x16, 0x2C,
1837 0x00, 0xE0, 0x08, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0x9A, 0x00,
1838 0x7E, 0x00, 0x00, 0x40, 0x2E, 0x00, 0x02, 0x00, 0xD0, 0x07, 0x00, 0x00, 0x21,
1839 0x00, 0x0D, 0x00, 0x14, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x03,
1840 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x02, 0x9A, 0x00, 0x00, 0x00, 0x00,
1841 0x80, 0x38, 0x03, 0x9A, 0x00, 0x23, 0x00, 0x30, 0x00, 0x00, 0x03, 0x9A, 0x00,
1842 0x25, 0x01, 0x00, 0x00, 0x54, 0x03, 0x9A, 0x00, 0x00, 0x00, 0x80, 0x00, 0x2E,
1843 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x09, 0x00, 0x30, 0x03,
1844 0x9A, 0x00, 0x30, 0x00, 0x10, 0x00, 0x48, 0x03, 0x9A, 0x00, 0x88, 0x00, 0x70,
1845 0x00, 0x38, 0xD6, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x04, 0xD6, 0x00, 0x00,
1846 0x01, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0x20, 0x4E, 0x00, 0x00, 0x21,
1847 0x00, 0x07, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x82, 0x18, 0x03,
1848 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x90, 0x8F,
1849 0x02, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00,
1850 0x78, 0x09, 0x9A, 0x00, 0x0F, 0x3E, 0x7A, 0x88, 0x30, 0x08, 0x9A, 0x00, 0x91,
1851 0x10, 0x27, 0x00, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0A, 0x88, 0x14, 0x09,
1852 0x90, 0x00, 0x00, 0x00, 0x0A, 0x88, 0x10, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0A,
1853 0x88, 0x14, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0A, 0x88, 0x00, 0x00, 0x02, 0x00,
1854 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x74, 0x09, 0x90, 0x00, 0x15,
1855 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x20, 0xA1, 0x07, 0x00, 0x01, 0x00,
1856 0x02, 0x00, 0x74, 0x49, 0x90, 0x00, 0x15, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00,
1857 0x00, 0x20, 0xA1, 0x07, 0x00, 0x21, 0x00, 0x05, 0x00, 0x30, 0x08, 0x9A, 0x00,
1858 0x91, 0x10, 0x27, 0x01, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10, 0x27, 0x00, 0x20,
1859 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00,
1860 0x02, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x00, 0x02, 0x9A,
1861 0x00, 0x00, 0x98, 0x8F, 0x02, 0x16, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
1862};
1863
1864/* HIGH SPEED TO LOW/MID SPEED */
1865static u8 seq_script_step32_gp106[] = {
1866 0x34, 0x00, 0x02, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x20, 0x00, 0x03, 0x00, 0x01,
1867 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x00, 0x0B, 0x00, 0x10, 0x09,
1868 0x90, 0x00, 0x00, 0x00, 0x0C, 0x24, 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0C,
1869 0x24, 0x10, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0C, 0x24, 0x14, 0x49, 0x90, 0x00,
1870 0x00, 0x00, 0x0C, 0x24, 0x10, 0x02, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E,
1871 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x10, 0x03,
1872 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00,
1873 0x00, 0x21, 0x00, 0x0D, 0x00, 0x48, 0x03, 0x9A, 0x00, 0x00, 0x00, 0x70, 0x00,
1874 0x00, 0x02, 0x9A, 0x00, 0x00, 0x10, 0x8F, 0x82, 0x14, 0x03, 0x9A, 0x00, 0x01,
1875 0x00, 0x00, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x10, 0x8F, 0x02, 0x90, 0x00,
1876 0x9A, 0x00, 0x61, 0x00, 0x00, 0x00, 0x90, 0x00, 0x9A, 0x00, 0x7F, 0x00, 0x00,
1877 0xC0, 0x2E, 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x35, 0x00,
1878 0x98, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x06, 0x9A, 0x00, 0x00,
1879 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00, 0x85, 0x8F, 0x8B, 0xF7, 0x38, 0x1F,
1880 0x9A, 0x00, 0x00, 0x00, 0x01, 0x00, 0x34, 0x1F, 0x9A, 0x00, 0x00, 0x00, 0x01,
1881 0x00, 0x34, 0x0D, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x08, 0x9A, 0x00,
1882 0xE7, 0x8F, 0x8B, 0xF7, 0x40, 0x0D, 0x9A, 0x00, 0x00, 0xE0, 0x01, 0x00, 0x24,
1883 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x83, 0x40, 0x08, 0x08, 0x9A, 0x00, 0x70, 0x00,
1884 0xA0, 0x4A, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x02, 0x30, 0x08, 0x9A,
1885 0x00, 0x90, 0x20, 0x67, 0x01, 0x30, 0x08, 0x9A, 0x00, 0x90, 0x20, 0x67, 0x00,
1886 0xF4, 0x73, 0x13, 0x00, 0x12, 0x11, 0x00, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x10,
1887 0x11, 0x00, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x20,
1888 0x13, 0x00, 0x00, 0x00, 0x03, 0x98, 0x00, 0x20, 0x13, 0x00, 0x02, 0x00, 0x03,
1889 0x98, 0x20, 0x20, 0x13, 0x00, 0x00, 0x00, 0x03, 0x20, 0x20, 0x73, 0x13, 0x00,
1890 0x00, 0x00, 0x00, 0x00, 0x30, 0x20, 0x13, 0x00, 0x06, 0x00, 0x00, 0x10, 0x34,
1891 0x20, 0x13, 0x00, 0x00, 0x10, 0x67, 0x06, 0x24, 0x20, 0x13, 0x00, 0x01, 0x3B,
1892 0x02, 0x00, 0x2C, 0x20, 0x13, 0x00, 0x00, 0x01, 0x00, 0x00, 0x28, 0x20, 0x13,
1893 0x00, 0x10, 0x00, 0x08, 0x10, 0x20, 0x20, 0x13, 0x00, 0x01, 0x00, 0x03, 0x20,
1894 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x90,
1895 0x73, 0x13, 0x00, 0x15, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0xFA,
1896 0x00, 0x00, 0x21, 0x00, 0x25, 0x00, 0x2C, 0x20, 0x13, 0x00, 0x00, 0x03, 0x00,
1897 0x00, 0x28, 0x20, 0x13, 0x00, 0x10, 0x00, 0x04, 0x10, 0xF4, 0x73, 0x13, 0x00,
1898 0x00, 0x11, 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x10, 0x11, 0x01, 0x00, 0xF0,
1899 0x73, 0x13, 0x00, 0x01, 0x00, 0x00, 0x00, 0xEC, 0x73, 0x13, 0x00, 0x00, 0x00,
1900 0x01, 0x00, 0xF4, 0x73, 0x13, 0x00, 0x11, 0x11, 0x01, 0x00, 0xF4, 0x73, 0x13,
1901 0x00, 0x11, 0x11, 0x00, 0x00, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x20, 0x27, 0x00,
1902 0x5C, 0x06, 0x9A, 0x00, 0x11, 0x00, 0x00, 0x00, 0x70, 0x06, 0x9A, 0x00, 0x06,
1903 0x13, 0x08, 0xB4, 0x98, 0x06, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x06,
1904 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x94, 0x06, 0x9A, 0x00, 0x0E, 0x06, 0x0E,
1905 0x06, 0x0C, 0x06, 0x9A, 0x00, 0x50, 0x20, 0x00, 0xFD, 0xD4, 0x0E, 0x9A, 0x00,
1906 0x00, 0x00, 0x00, 0x40, 0xD4, 0x0E, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24,
1907 0x08, 0x9A, 0x00, 0xE7, 0x8F, 0x80, 0x40, 0x13, 0x00, 0x02, 0x00, 0x2C, 0x01,
1908 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0x10, 0x27, 0x00, 0x00, 0x21, 0x00, 0x25,
1909 0x00, 0x70, 0x06, 0x9A, 0x00, 0x06, 0x13, 0x08, 0x34, 0x2C, 0x08, 0x9A, 0x00,
1910 0x00, 0x00, 0x15, 0x00, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10, 0x27, 0x00, 0x48,
1911 0x02, 0x9A, 0x00, 0xA3, 0x44, 0x14, 0x86, 0x90, 0x02, 0x9A, 0x00, 0x12, 0x2C,
1912 0x18, 0x06, 0x94, 0x02, 0x9A, 0x00, 0x8A, 0x82, 0x41, 0x24, 0x98, 0x02, 0x9A,
1913 0x00, 0x11, 0x05, 0x06, 0x88, 0x9C, 0x02, 0x9A, 0x00, 0x8C, 0x10, 0x00, 0x22,
1914 0xA0, 0x02, 0x9A, 0x00, 0x32, 0x00, 0x61, 0xD3, 0xA8, 0x02, 0x9A, 0x00, 0x0B,
1915 0x86, 0x00, 0x01, 0x14, 0x06, 0x9A, 0x00, 0x77, 0x3E, 0x03, 0x30, 0x10, 0x06,
1916 0x9A, 0x00, 0x77, 0x3E, 0x03, 0x30, 0x08, 0x08, 0x9A, 0x00, 0x70, 0x00, 0x00,
1917 0x48, 0x78, 0x07, 0x10, 0x00, 0x33, 0x03, 0x00, 0x82, 0x4C, 0x02, 0x9A, 0x00,
1918 0x85, 0x0C, 0x05, 0x06, 0x30, 0x1F, 0x9A, 0x00, 0x03, 0x16, 0x2C, 0x00, 0xE0,
1919 0x08, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0x9A, 0x00, 0x7E, 0x00,
1920 0x00, 0x40, 0x2E, 0x00, 0x02, 0x00, 0xD0, 0x07, 0x00, 0x00, 0x21, 0x00, 0x0D,
1921 0x00, 0x14, 0x03, 0x9A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x03, 0x9A, 0x00,
1922 0x01, 0x00, 0x00, 0x00, 0x10, 0x02, 0x9A, 0x00, 0x00, 0x00, 0x00, 0x80, 0x38,
1923 0x03, 0x9A, 0x00, 0x23, 0x01, 0x30, 0x00, 0x00, 0x03, 0x9A, 0x00, 0x2D, 0x02,
1924 0x00, 0x00, 0x54, 0x03, 0x9A, 0x00, 0x00, 0x00, 0x80, 0x00, 0x2E, 0x00, 0x02,
1925 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x09, 0x00, 0x30, 0x03, 0x9A, 0x00,
1926 0x30, 0x00, 0x10, 0x00, 0x48, 0x03, 0x9A, 0x00, 0x88, 0x00, 0x70, 0x00, 0x38,
1927 0xD6, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x04, 0xD6, 0x00, 0x00, 0x01, 0x00,
1928 0x00, 0x00, 0x2E, 0x00, 0x02, 0x00, 0x20, 0x4E, 0x00, 0x00, 0x21, 0x00, 0x07,
1929 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x82, 0x18, 0x03, 0x9A, 0x00,
1930 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x90, 0x8F, 0x02, 0x2E,
1931 0x00, 0x02, 0x00, 0xE8, 0x03, 0x00, 0x00, 0x21, 0x00, 0x0D, 0x00, 0x78, 0x09,
1932 0x9A, 0x00, 0x0B, 0x1E, 0x7A, 0x88, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10, 0x27,
1933 0x00, 0x10, 0x09, 0x90, 0x00, 0x00, 0x00, 0x0A, 0x98, 0x14, 0x09, 0x90, 0x00,
1934 0x00, 0x00, 0x0A, 0x98, 0x10, 0x49, 0x90, 0x00, 0x00, 0x00, 0x0A, 0x98, 0x14,
1935 0x49, 0x90, 0x00, 0x00, 0x00, 0x0A, 0x98, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
1936 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x74, 0x09, 0x90, 0x00, 0x15, 0x00, 0x03,
1937 0x00, 0x0F, 0x00, 0x00, 0x00, 0x20, 0xA1, 0x07, 0x00, 0x01, 0x00, 0x02, 0x00,
1938 0x74, 0x49, 0x90, 0x00, 0x15, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x20,
1939 0xA1, 0x07, 0x00, 0x21, 0x00, 0x0D, 0x00, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10,
1940 0x27, 0x01, 0x30, 0x08, 0x9A, 0x00, 0x91, 0x10, 0x27, 0x00, 0x10, 0x09, 0x90,
1941 0x00, 0x00, 0x00, 0x08, 0x19, 0x14, 0x09, 0x90, 0x00, 0x00, 0x00, 0x08, 0x19,
1942 0x10, 0x49, 0x90, 0x00, 0x00, 0x00, 0x08, 0x19, 0x14, 0x49, 0x90, 0x00, 0x00,
1943 0x00, 0x08, 0x19, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1944 0x00, 0x00, 0x34, 0x00, 0x02, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03,
1945 0x00, 0x00, 0x02, 0x9A, 0x00, 0x00, 0x98, 0x8F, 0x02, 0x16, 0x00, 0x02, 0x00,
1946 0x00, 0x00, 0x00, 0x00,
1947};
1948
1949#ifdef CONFIG_DEBUG_FS
1950static int mclk_debugfs_init(struct gk20a *g);
1951#endif
1952
1953static void mclk_memory_load_training_pattern(struct gk20a *g)
1954{
1955 u32 reg_writes;
1956 u32 index;
1957
1958 gk20a_dbg_info("");
1959
1960 reg_writes = ((sizeof(memory_pattern_reglist) /
1961 sizeof((memory_pattern_reglist)[0])));
1962
1963 for (index = 0; index < reg_writes; index++) {
1964 gk20a_writel(g, memory_pattern_reglist[index].regaddr,
1965 memory_pattern_reglist[index].writeval);
1966 }
1967
1968 gk20a_dbg_fn("done");
1969}
1970
1971static void mclk_seq_pmucmdhandler(struct gk20a *g, struct pmu_msg *_msg,
1972 void *param, u32 handle, u32 status)
1973{
1974 struct nv_pmu_seq_msg *msg = (struct nv_pmu_seq_msg *)_msg;
1975 struct nv_pmu_seq_msg_run_script *seq_msg;
1976 u32 msg_status = 0;
1977
1978 gk20a_dbg_info("");
1979
1980 if (status != 0) {
1981 gk20a_err(dev_from_gk20a(g), "mclk seq_script cmd aborted");
1982 msg_status = -ENOENT;
1983 goto status_update;
1984 }
1985
1986 seq_msg = &msg->run_script;
1987
1988 if (seq_msg->msg_type != NV_PMU_SEQ_MSG_ID_RUN_SCRIPT) {
1989 msg_status = -ENOENT;
1990 goto status_update;
1991 }
1992
1993 if (seq_msg->error_code) {
1994 msg_status = -ENOENT;
1995 goto status_update;
1996 }
1997
1998status_update:
1999 *((u32 *)param) = msg_status;
2000}
2001
2002static int mclk_get_memclk_table(struct gk20a *g)
2003{
2004 int status = 0;
2005 u8 *mem_table_ptr = NULL;
2006 u32 idx_to_ptr_tbl[8];
2007 u32 idx_to_cmd_ptr_tbl[8];
2008
2009 u32 old_fbio_delay;
2010 u32 old_fbio_cmd_delay;
2011
2012 u32 cmd_idx;
2013 u32 shadow_idx;
2014
2015 struct vbios_memory_clock_header_1x memclock_table_header = { 0 };
2016 struct vbios_memory_clock_base_entry_11 memclock_base_entry = { 0 };
2017
2018 u8 *mem_entry_ptr = NULL;
2019 int index;
2020
2021 gk20a_dbg_info("");
2022
2023 if (!(g->ops.bios.get_perf_table_ptrs &&
2024 g->ops.bios.execute_script)) {
2025 goto done;
2026 }
2027
2028 mem_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
2029 g->bios.perf_token,
2030 MEMORY_CLOCK_TABLE);
2031 if (mem_table_ptr == NULL) {
2032 status = -EPERM;
2033 goto done;
2034 }
2035
2036 memcpy(&memclock_table_header, mem_table_ptr,
2037 sizeof(memclock_table_header));
2038
2039 if ((memclock_table_header.version <
2040 VBIOS_MEMORY_CLOCK_HEADER_11_VERSION) ||
2041 (memclock_table_header.base_entry_size <
2042 VBIOS_MEMORY_CLOCK_BASE_ENTRY_11_2_SIZE)) {
2043 status = -EINVAL;
2044 goto done;
2045 }
2046
2047 /* reset and save shadow table map and registers */
2048 old_fbio_delay = gk20a_readl(g, fb_fbpa_fbio_delay_r());
2049 old_fbio_cmd_delay = gk20a_readl(g, fb_fbpa_fbio_cmd_delay_r());
2050
2051 memset(idx_to_ptr_tbl, 0, sizeof(idx_to_ptr_tbl));
2052 memset(idx_to_cmd_ptr_tbl, 0, sizeof(idx_to_cmd_ptr_tbl));
2053
2054 /* Read table entries */
2055 mem_entry_ptr = mem_table_ptr + memclock_table_header.header_size;
2056 for (index = 0; index < memclock_table_header.entry_count; index++) {
2057 u8 script_index, cmd_script_index;
2058 u32 script_ptr = 0, cmd_script_ptr = 0;
2059
2060 memcpy(&memclock_base_entry, mem_entry_ptr,
2061 memclock_table_header.base_entry_size);
2062 if (memclock_base_entry.maximum == 0)
2063 continue;
2064
2065 script_index = BIOS_GET_FIELD(memclock_base_entry.flags1,
2066 VBIOS_MEMORY_CLOCK_BASE_ENTRY_11_FLAGS1_SCRIPT_INDEX);
2067
2068 script_ptr = gm206_bios_read_u32(g,
2069 memclock_table_header.script_list_ptr +
2070 script_index * sizeof(u32));
2071
2072 if (!script_ptr)
2073 continue;
2074
2075 /* Link and execute shadow scripts */
2076
2077 for (shadow_idx = 0; shadow_idx <= fb_fbpa_fbio_delay_priv_max_v();
2078 ++shadow_idx) {
2079 if (script_ptr == idx_to_ptr_tbl[shadow_idx]) {
2080 break;
2081 }
2082 }
2083
2084 /* script has not been executed before */
2085 if (shadow_idx > fb_fbpa_fbio_delay_priv_max_v()) {
2086 /* find unused index */
2087 for (shadow_idx = 0; shadow_idx <
2088 fb_fbpa_fbio_delay_priv_max_v();
2089 ++shadow_idx) {
2090 if (idx_to_ptr_tbl[shadow_idx] == 0)
2091 break;
2092 }
2093
2094 if (shadow_idx > fb_fbpa_fbio_delay_priv_max_v()) {
2095 gk20a_err(dev_from_gk20a(g),
2096 "invalid shadow reg script index");
2097 status = -EINVAL;
2098 goto done;
2099 }
2100
2101 idx_to_ptr_tbl[shadow_idx] = script_ptr;
2102
2103 gk20a_writel(g, fb_fbpa_fbio_delay_r(),
2104 set_field(old_fbio_delay,
2105 fb_fbpa_fbio_delay_priv_m(),
2106 fb_fbpa_fbio_delay_priv_f(shadow_idx)));
2107
2108 status = g->ops.bios.execute_script(g, script_ptr);
2109 if (status < 0) {
2110 gk20a_writel(g, fb_fbpa_fbio_delay_r(),
2111 old_fbio_delay);
2112 goto done;
2113 }
2114
2115 gk20a_writel(g, fb_fbpa_fbio_delay_r(), old_fbio_delay);
2116
2117 }
2118
2119 cmd_script_index = BIOS_GET_FIELD(memclock_base_entry.flags2,
2120 VBIOS_MEMORY_CLOCK_BASE_ENTRY_12_FLAGS2_CMD_SCRIPT_INDEX);
2121
2122 cmd_script_ptr = gm206_bios_read_u32(g,
2123 memclock_table_header.cmd_script_list_ptr +
2124 cmd_script_index * sizeof(u32));
2125
2126 if (!cmd_script_ptr)
2127 continue;
2128
2129 /* Link and execute cmd shadow scripts */
2130 for (cmd_idx = 0; cmd_idx <= fb_fbpa_fbio_cmd_delay_cmd_priv_max_v();
2131 ++cmd_idx) {
2132 if (cmd_script_ptr == idx_to_cmd_ptr_tbl[cmd_idx])
2133 break;
2134 }
2135
2136 /* script has not been executed before */
2137 if (cmd_idx > fb_fbpa_fbio_cmd_delay_cmd_priv_max_v()) {
2138 /* find unused index */
2139 for (cmd_idx = 0; cmd_idx <
2140 fb_fbpa_fbio_cmd_delay_cmd_priv_max_v();
2141 ++cmd_idx) {
2142 if (idx_to_cmd_ptr_tbl[cmd_idx] == 0)
2143 break;
2144 }
2145
2146 if (cmd_idx > fb_fbpa_fbio_cmd_delay_cmd_priv_max_v()) {
2147 gk20a_err(dev_from_gk20a(g),
2148 "invalid shadow reg cmd script index");
2149 status = -EINVAL;
2150 goto done;
2151 }
2152
2153 idx_to_cmd_ptr_tbl[cmd_idx] = cmd_script_ptr;
2154 gk20a_writel(g, fb_fbpa_fbio_cmd_delay_r(),
2155 set_field(old_fbio_cmd_delay,
2156 fb_fbpa_fbio_cmd_delay_cmd_priv_m(),
2157 fb_fbpa_fbio_cmd_delay_cmd_priv_f(
2158 cmd_idx)));
2159
2160 status = g->ops.bios.execute_script(g, cmd_script_ptr);
2161 if (status < 0) {
2162 gk20a_writel(g, fb_fbpa_fbio_cmd_delay_r(),
2163 old_fbio_cmd_delay);
2164 goto done;
2165 }
2166
2167 gk20a_writel(g, fb_fbpa_fbio_cmd_delay_r(),
2168 old_fbio_cmd_delay);
2169
2170 }
2171
2172 mem_entry_ptr += memclock_table_header.base_entry_size +
2173 memclock_table_header.strap_entry_count *
2174 memclock_table_header.strap_entry_size;
2175 }
2176
2177done:
2178 return status;
2179}
2180
2181int clk_mclkseq_init_mclk_gddr5(struct gk20a *g)
2182{
2183 struct clk_mclk_state *mclk;
2184 int status;
2185 struct clk_set_info *p5_info;
2186 struct clk_set_info *p0_info;
2187
2188
2189 gk20a_dbg_fn("");
2190
2191 mclk = &g->clk_pmu.clk_mclk;
2192
2193 mutex_init(&mclk->mclk_lock);
2194 mutex_init(&mclk->data_lock);
2195
2196 /* FBPA gain WAR */
2197 gk20a_writel(g, fb_fbpa_fbio_iref_byte_rx_ctrl_r(), 0x22222222);
2198
2199 mclk->speed = gk20a_mclk_low_speed; /* Value from Devinit */
2200
2201 /* Parse VBIOS */
2202 status = mclk_get_memclk_table(g);
2203 if (status < 0)
2204 return status;
2205
2206 /* Load RAM pattern */
2207 mclk_memory_load_training_pattern(g);
2208
2209 p5_info = pstate_get_clk_set_info(g,
2210 CTRL_PERF_PSTATE_P5, clkwhich_mclk);
2211 if (!p5_info)
2212 return -EINVAL;
2213
2214 p0_info = pstate_get_clk_set_info(g,
2215 CTRL_PERF_PSTATE_P0, clkwhich_mclk);
2216 if (!p0_info)
2217 return -EINVAL;
2218
2219
2220 mclk->p5_min = p5_info->min_mhz;
2221 mclk->p0_min = p0_info->min_mhz;
2222
2223
2224 mclk->vreg_buf = kcalloc(VREG_COUNT,
2225 sizeof(u32), GFP_KERNEL);
2226 if (!mclk->vreg_buf) {
2227 gk20a_err(dev_from_gk20a(g),
2228 "unable to allocate memory for VREG");
2229 return -ENOMEM;
2230 }
2231
2232#ifdef CONFIG_DEBUG_FS
2233 if (!mclk->debugfs_set) {
2234 if (mclk_debugfs_init(g))
2235 mclk->debugfs_set = true;
2236 }
2237#endif
2238 mclk->change = clk_mclkseq_change_mclk_gddr5;
2239
2240 mclk->init = true;
2241
2242 return 0;
2243}
2244
2245int clk_mclkseq_change_mclk_gddr5(struct gk20a *g, u16 val)
2246{
2247 struct clk_mclk_state *mclk;
2248 struct pmu_payload payload = { {0} };
2249 struct nv_pmu_seq_cmd cmd;
2250 struct nv_pmu_seq_cmd_run_script *pseq_cmd;
2251 u32 seqdesc;
2252 int status = 0;
2253 u32 seq_completion_status = ~0x0;
2254 u8 *seq_script_ptr = NULL;
2255 size_t seq_script_size = 0;
2256#ifdef CONFIG_DEBUG_FS
2257 u64 t0, t1;
2258#endif
2259 enum gk20a_mclk_speed speed;
2260
2261 gk20a_dbg_info("");
2262
2263 mclk = &g->clk_pmu.clk_mclk;
2264
2265 mutex_lock(&mclk->mclk_lock);
2266
2267 if (!mclk->init)
2268 goto exit_status;
2269
2270 speed = (val < mclk->p5_min) ? gk20a_mclk_low_speed :
2271 (val < mclk->p0_min) ? gk20a_mclk_mid_speed :
2272 gk20a_mclk_high_speed;
2273
2274
2275 if (speed == mclk->speed)
2276 goto exit_status;
2277
2278 switch (speed) {
2279 case gk20a_mclk_mid_speed:
2280 if (mclk->speed == gk20a_mclk_low_speed) {
2281 seq_script_ptr = seq_script_step33_gp106;
2282 seq_script_size = sizeof(seq_script_step33_gp106);
2283 } else {
2284 seq_script_ptr = seq_script_step32_gp106;
2285 seq_script_size = sizeof(seq_script_step32_gp106);
2286 }
2287 break;
2288 case gk20a_mclk_high_speed:
2289 seq_script_ptr = seq_script_step28_gp106;
2290 seq_script_size = sizeof(seq_script_step28_gp106);
2291 break;
2292 case gk20a_mclk_low_speed:
2293 if (mclk->speed == gk20a_mclk_mid_speed) {
2294 seq_script_ptr = seq_script_step33_ls_gp106;
2295 seq_script_size = sizeof(seq_script_step33_ls_gp106);
2296 } else {
2297 seq_script_ptr = seq_script_step32_ls_gp106;
2298 seq_script_size = sizeof(seq_script_step32_ls_gp106);
2299 }
2300 break;
2301 default:
2302 gk20a_err(dev_from_gk20a(g),
2303 "Illegal MCLK clock change");
2304 status = -EINVAL;
2305 goto exit_status;
2306 }
2307
2308 /* Fill command header with SEQ ID & size */
2309 memset(&cmd, 0, sizeof(cmd));
2310 cmd.hdr.unit_id = PMU_UNIT_SEQ;
2311 cmd.hdr.size = sizeof(struct nv_pmu_seq_cmd_run_script) +
2312 sizeof(struct pmu_hdr);
2313
2314 /* Fill RM_PMU_SEQ_CMD_RUN_SCRIPT struct */
2315 pseq_cmd = &cmd.run_script;
2316 pseq_cmd->cmd_type = NV_PMU_SEQ_CMD_ID_RUN_SCRIPT;
2317
2318#ifdef CONFIG_DEBUG_FS
2319 g->ops.read_ptimer(g, &t0);
2320#endif
2321
2322 if (speed == gk20a_mclk_high_speed) {
2323 gk20a_writel(g, 0x132000, 0x98010000);
2324 /* Introduce delay */
2325 gk20a_readl(g, 0x132000);
2326 gk20a_readl(g, 0x132000);
2327 }
2328
2329 gk20a_writel(g, 0x137300, 0x20000103);
2330
2331 /* Read sequencer binary*/
2332 payload.in.buf = seq_script_ptr;
2333 payload.in.size = seq_script_size;
2334 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
2335 payload.in.offset = offsetof(struct nv_pmu_seq_cmd_run_script,
2336 script_alloc);
2337
2338 memset(mclk->vreg_buf, 0, (sizeof(u32) * VREG_COUNT));
2339
2340 payload.out.buf = mclk->vreg_buf;
2341 payload.out.size = (VREG_COUNT * sizeof(u32));
2342 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
2343 payload.out.offset = offsetof(struct nv_pmu_seq_cmd_run_script,
2344 reg_alloc);
2345
2346 /* Send command to PMU to execute sequencer script */
2347 status = gk20a_pmu_cmd_post(g, (struct pmu_cmd *)&cmd, NULL, &payload,
2348 PMU_COMMAND_QUEUE_LPQ,
2349 mclk_seq_pmucmdhandler,
2350 &seq_completion_status, &seqdesc, ~0);
2351 if (status) {
2352 gk20a_err(dev_from_gk20a(g),
2353 "unable to post seq script exec cmd for unit %x ",
2354 cmd.hdr.unit_id);
2355 goto exit_status;
2356 }
2357 /* wait till sequencer script complete */
2358 pmu_wait_message_cond(&g->pmu, (gk20a_get_gr_idle_timeout(g)),
2359 &seq_completion_status, 0);
2360 if (seq_completion_status != 0) {
2361 gk20a_err(dev_from_gk20a(g),
2362 "seq_script update failed");
2363 status = -EBUSY;
2364 goto exit_status;
2365 }
2366
2367 mclk->speed = speed;
2368
2369#ifdef CONFIG_DEBUG_FS
2370 g->ops.read_ptimer(g, &t1);
2371
2372 mutex_lock(&mclk->data_lock);
2373 mclk->switch_num++;
2374
2375 if (mclk->switch_num == 1) {
2376 mclk->switch_max = mclk->switch_min =
2377 mclk->switch_avg = (t1-t0)/1000;
2378 mclk->switch_std = 0;
2379 } else {
2380 s64 prev_avg;
2381 s64 curr = (t1-t0)/1000;
2382
2383 mclk->switch_max = curr > mclk->switch_max ?
2384 curr : mclk->switch_max;
2385 mclk->switch_min = mclk->switch_min ?
2386 (curr < mclk->switch_min ?
2387 curr : mclk->switch_min) : curr;
2388 prev_avg = mclk->switch_avg;
2389 mclk->switch_avg = (curr +
2390 (mclk->switch_avg * (mclk->switch_num-1))) /
2391 mclk->switch_num;
2392 mclk->switch_std +=
2393 (curr - mclk->switch_avg) * (curr - prev_avg);
2394 }
2395 mutex_unlock(&mclk->data_lock);
2396#endif
2397exit_status:
2398
2399 mutex_unlock(&mclk->mclk_lock);
2400 return status;
2401}
2402
2403#ifdef CONFIG_DEBUG_FS
2404static int mclk_debug_speed_set(void *data, u64 val)
2405{
2406 struct gk20a *g = (struct gk20a *) data;
2407 struct clk_mclk_state *mclk;
2408
2409 mclk = &g->clk_pmu.clk_mclk;
2410
2411 /* This is problematic because it can interrupt the arbiter
2412 * and send it to sleep. we need to consider removing this
2413 */
2414 if (mclk->change)
2415 return mclk->change(g, (u16) val);
2416 return 0;
2417
2418}
2419
2420DEFINE_SIMPLE_ATTRIBUTE(
2421 mclk_debug_speed_set_fops,
2422 NULL,
2423 mclk_debug_speed_set,
2424 "%llu\n"
2425);
2426
2427static int mclk_switch_stats_show(struct seq_file *s, void *unused)
2428{
2429 struct gk20a *g = s->private;
2430 struct clk_mclk_state *mclk;
2431 u64 num;
2432 s64 tmp, avg, std, max, min;
2433
2434 mclk = &g->clk_pmu.clk_mclk;
2435
2436 /* Make copy of structure to reduce time with lock held */
2437 mutex_lock(&mclk->data_lock);
2438 std = mclk->switch_std;
2439 avg = mclk->switch_avg;
2440 max = mclk->switch_max;
2441 min = mclk->switch_min;
2442 num = mclk->switch_num;
2443 mutex_unlock(&mclk->data_lock);
2444
2445 tmp = std;
2446 do_div(tmp, num);
2447 seq_printf(s, "MCLK:\n number of transitions: %lld\n",
2448 num);
2449 seq_printf(s, "max / min : %lld / %lld usec\n",
2450 max, min);
2451 seq_printf(s, "avg / std : %lld / %ld usec\n",
2452 avg, int_sqrt(tmp));
2453
2454 return 0;
2455}
2456
2457static int mclk_switch_stats_open(struct inode *inode, struct file *file)
2458{
2459 return single_open(file, mclk_switch_stats_show, inode->i_private);
2460}
2461
2462static const struct file_operations mclk_switch_stats_fops = {
2463 .open = mclk_switch_stats_open,
2464 .read = seq_read,
2465 .llseek = seq_lseek,
2466 .release = single_release,
2467};
2468
2469
2470static int mclk_debugfs_init(struct gk20a *g)
2471{
2472 struct gk20a_platform *platform = dev_get_drvdata(g->dev);
2473
2474 struct dentry *gpu_root = platform->debugfs;
2475 struct dentry *d;
2476
2477 gk20a_dbg(gpu_dbg_info, "g=%p", g);
2478
2479 d = debugfs_create_file(
2480 "mclk_speed_set",
2481 S_IWUGO,
2482 gpu_root,
2483 g,
2484 &mclk_debug_speed_set_fops);
2485 if (!d)
2486 return -ENOMEM;
2487
2488 d = debugfs_create_file(
2489 "mclk_switch_stats",
2490 S_IRUGO,
2491 gpu_root,
2492 g,
2493 &mclk_switch_stats_fops);
2494 if (!d)
2495 return -ENOMEM;
2496
2497 return 0;
2498}
2499#endif
diff --git a/drivers/gpu/nvgpu/clk/clk_mclk.h b/drivers/gpu/nvgpu/clk/clk_mclk.h
new file mode 100644
index 00000000..cb7f0de0
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_mclk.h
@@ -0,0 +1,52 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _CLKMCLK_H_
15#define _CLKMCLK_H_
16
17#include <linux/mutex.h>
18
19enum gk20a_mclk_speed {
20 gk20a_mclk_low_speed,
21 gk20a_mclk_mid_speed,
22 gk20a_mclk_high_speed,
23};
24
25struct clk_mclk_state {
26 enum gk20a_mclk_speed speed;
27 struct mutex mclk_lock;
28 struct mutex data_lock;
29
30 u16 p5_min;
31 u16 p0_min;
32
33 void *vreg_buf;
34 bool init;
35
36 /* function pointers */
37 int (*change)(struct gk20a *g, u16 val);
38
39#ifdef CONFIG_DEBUG_FS
40 s64 switch_max;
41 s64 switch_min;
42 u64 switch_num;
43 s64 switch_avg;
44 s64 switch_std;
45 bool debugfs_set;
46#endif
47};
48
49int clk_mclkseq_init_mclk_gddr5(struct gk20a *g);
50int clk_mclkseq_change_mclk_gddr5(struct gk20a *g, u16 val);
51
52#endif
diff --git a/drivers/gpu/nvgpu/clk/clk_prog.c b/drivers/gpu/nvgpu/clk/clk_prog.c
new file mode 100644
index 00000000..6b81650e
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_prog.c
@@ -0,0 +1,1098 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "clk.h"
16#include "clk_prog.h"
17#include "clk_vf_point.h"
18#include "include/bios.h"
19#include "boardobj/boardobjgrp.h"
20#include "boardobj/boardobjgrp_e32.h"
21#include "pmuif/gpmuifboardobj.h"
22#include "pmuif/gpmuifclk.h"
23#include "gm206/bios_gm206.h"
24#include "ctrl/ctrlclk.h"
25#include "ctrl/ctrlvolt.h"
26#include "gk20a/pmu_gk20a.h"
27
28static struct clk_prog *construct_clk_prog(struct gk20a *g, void *pargs);
29static u32 devinit_get_clk_prog_table(struct gk20a *g,
30 struct clk_progs *pprogobjs);
31static vf_flatten vfflatten_prog_1x_master;
32static vf_lookup vflookup_prog_1x_master;
33static get_fpoints getfpoints_prog_1x_master;
34static get_slaveclk getslaveclk_prog_1x_master;
35
36static u32 _clk_progs_pmudatainit(struct gk20a *g,
37 struct boardobjgrp *pboardobjgrp,
38 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu)
39{
40 struct nv_pmu_clk_clk_prog_boardobjgrp_set_header *pset =
41 (struct nv_pmu_clk_clk_prog_boardobjgrp_set_header *)
42 pboardobjgrppmu;
43 struct clk_progs *pprogs = (struct clk_progs *)pboardobjgrp;
44 u32 status = 0;
45
46 status = boardobjgrp_pmudatainit_e32(g, pboardobjgrp, pboardobjgrppmu);
47 if (status) {
48 gk20a_err(dev_from_gk20a(g),
49 "error updating pmu boardobjgrp for clk prog 0x%x",
50 status);
51 goto done;
52 }
53 pset->slave_entry_count = pprogs->slave_entry_count;
54 pset->vf_entry_count = pprogs->vf_entry_count;
55
56done:
57 return status;
58}
59
60static u32 _clk_progs_pmudata_instget(struct gk20a *g,
61 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
62 struct nv_pmu_boardobj **ppboardobjpmudata,
63 u8 idx)
64{
65 struct nv_pmu_clk_clk_prog_boardobj_grp_set *pgrp_set =
66 (struct nv_pmu_clk_clk_prog_boardobj_grp_set *)pmuboardobjgrp;
67
68 gk20a_dbg_info("");
69
70 /*check whether pmuboardobjgrp has a valid boardobj in index*/
71 if (((u32)BIT(idx) &
72 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
73 return -EINVAL;
74
75 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
76 &pgrp_set->objects[idx].data.board_obj;
77 gk20a_dbg_info(" Done");
78 return 0;
79}
80
81u32 clk_prog_sw_setup(struct gk20a *g)
82{
83 u32 status;
84 struct boardobjgrp *pboardobjgrp = NULL;
85 struct clk_progs *pclkprogobjs;
86
87 gk20a_dbg_info("");
88
89 status = boardobjgrpconstruct_e255(&g->clk_pmu.clk_progobjs.super);
90 if (status) {
91 gk20a_err(dev_from_gk20a(g),
92 "error creating boardobjgrp for clk prog, status - 0x%x",
93 status);
94 goto done;
95 }
96
97 pboardobjgrp = &g->clk_pmu.clk_progobjs.super.super;
98 pclkprogobjs = &(g->clk_pmu.clk_progobjs);
99
100 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, CLK, CLK_PROG);
101
102 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
103 clk, CLK, clk_prog, CLK_PROG);
104 if (status) {
105 gk20a_err(dev_from_gk20a(g),
106 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
107 status);
108 goto done;
109 }
110
111 pboardobjgrp->pmudatainit = _clk_progs_pmudatainit;
112 pboardobjgrp->pmudatainstget = _clk_progs_pmudata_instget;
113
114 status = devinit_get_clk_prog_table(g, pclkprogobjs);
115 if (status)
116 goto done;
117
118 status = clk_domain_clk_prog_link(g, &g->clk_pmu);
119 if (status) {
120 gk20a_err(dev_from_gk20a(g),
121 "error constructing VF point board objects");
122 goto done;
123 }
124
125
126done:
127 gk20a_dbg_info(" done status %x", status);
128 return status;
129}
130
131u32 clk_prog_pmu_setup(struct gk20a *g)
132{
133 u32 status;
134 struct boardobjgrp *pboardobjgrp = NULL;
135
136 gk20a_dbg_info("");
137
138 pboardobjgrp = &g->clk_pmu.clk_progobjs.super.super;
139
140 if (!pboardobjgrp->bconstructed)
141 return -EINVAL;
142
143 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
144
145 gk20a_dbg_info("Done");
146 return status;
147}
148
149static u32 devinit_get_clk_prog_table(struct gk20a *g,
150 struct clk_progs *pclkprogobjs)
151{
152 u32 status = 0;
153 u8 *clkprogs_tbl_ptr = NULL;
154 struct vbios_clock_programming_table_1x_header header = { 0 };
155 struct vbios_clock_programming_table_1x_entry prog = { 0 };
156 struct vbios_clock_programming_table_1x_slave_entry slaveprog = { 0 };
157 struct vbios_clock_programming_table_1x_vf_entry vfprog = { 0 };
158 u8 *entry = NULL;
159 u8 *slaveentry = NULL;
160 u8 *vfentry = NULL;
161 u32 i, j = 0;
162 struct clk_prog *pprog;
163 u8 prog_type;
164 u32 szfmt = VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_SIZE_0D;
165 u32 hszfmt = VBIOS_CLOCK_PROGRAMMING_TABLE_1X_HEADER_SIZE_08;
166 u32 slaveszfmt = VBIOS_CLOCK_PROGRAMMING_TABLE_1X_SLAVE_ENTRY_SIZE_03;
167 u32 vfszfmt = VBIOS_CLOCK_PROGRAMMING_TABLE_1X_VF_ENTRY_SIZE_02;
168 struct ctrl_clk_clk_prog_1x_master_vf_entry
169 vfentries[CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES];
170 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry
171 ratioslaveentries[CTRL_CLK_PROG_1X_MASTER_MAX_SLAVE_ENTRIES];
172 struct ctrl_clk_clk_prog_1x_master_table_slave_entry
173 tableslaveentries[CTRL_CLK_PROG_1X_MASTER_MAX_SLAVE_ENTRIES];
174 union {
175 struct boardobj board_obj;
176 struct clk_prog clkprog;
177 struct clk_prog_1x v1x;
178 struct clk_prog_1x_master v1x_master;
179 struct clk_prog_1x_master_ratio v1x_master_ratio;
180 struct clk_prog_1x_master_table v1x_master_table;
181 } prog_data;
182
183 gk20a_dbg_info("");
184
185 if (g->ops.bios.get_perf_table_ptrs) {
186 clkprogs_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
187 g->bios.clock_token, CLOCK_PROGRAMMING_TABLE);
188 if (clkprogs_tbl_ptr == NULL) {
189 status = -EINVAL;
190 goto done;
191 }
192 }
193
194 memcpy(&header, clkprogs_tbl_ptr, hszfmt);
195 if (header.header_size < hszfmt) {
196 status = -EINVAL;
197 goto done;
198 }
199 hszfmt = header.header_size;
200
201 if (header.entry_size <= VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_SIZE_05)
202 szfmt = header.entry_size;
203 else if (header.entry_size <= VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_SIZE_0D)
204 szfmt = header.entry_size;
205 else {
206 status = -EINVAL;
207 goto done;
208 }
209
210 if (header.vf_entry_size < vfszfmt) {
211 status = -EINVAL;
212 goto done;
213 }
214 vfszfmt = header.vf_entry_size;
215 if (header.slave_entry_size < slaveszfmt) {
216 status = -EINVAL;
217 goto done;
218 }
219 slaveszfmt = header.slave_entry_size;
220 if (header.vf_entry_count > CTRL_CLK_CLK_DELTA_MAX_VOLT_RAILS) {
221 status = -EINVAL;
222 goto done;
223 }
224
225 pclkprogobjs->slave_entry_count = header.slave_entry_count;
226 pclkprogobjs->vf_entry_count = header.vf_entry_count;
227
228 for (i = 0; i < header.entry_count; i++) {
229 memset(&prog_data, 0x0, (u32)sizeof(prog_data));
230
231 /* Read table entries*/
232 entry = clkprogs_tbl_ptr + hszfmt +
233 (i * (szfmt + (header.slave_entry_count * slaveszfmt) +
234 (header.vf_entry_count * vfszfmt)));
235
236 memcpy(&prog, entry, szfmt);
237 memset(vfentries, 0xFF,
238 sizeof(struct ctrl_clk_clk_prog_1x_master_vf_entry) *
239 CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES);
240 memset(ratioslaveentries, 0xFF,
241 sizeof(struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry) *
242 CTRL_CLK_PROG_1X_MASTER_MAX_SLAVE_ENTRIES);
243 memset(tableslaveentries, 0xFF,
244 sizeof(struct ctrl_clk_clk_prog_1x_master_table_slave_entry) *
245 CTRL_CLK_PROG_1X_MASTER_MAX_SLAVE_ENTRIES);
246 prog_type = (u8)BIOS_GET_FIELD(prog.flags0,
247 NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_SOURCE);
248
249 switch (prog_type) {
250 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_SOURCE_PLL:
251 prog_data.v1x.source = CTRL_CLK_PROG_1X_SOURCE_PLL;
252 prog_data.v1x.source_data.pll.pll_idx =
253 (u8)BIOS_GET_FIELD(prog.param0,
254 NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_PARAM0_PLL_PLL_INDEX);
255 prog_data.v1x.source_data.pll.freq_step_size_mhz =
256 (u8)BIOS_GET_FIELD(prog.param1,
257 NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_PARAM1_PLL_FREQ_STEP_SIZE);
258 break;
259
260 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_SOURCE_ONE_SOURCE:
261 prog_data.v1x.source = CTRL_CLK_PROG_1X_SOURCE_ONE_SOURCE;
262 break;
263
264 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_SOURCE_FLL:
265 prog_data.v1x.source = CTRL_CLK_PROG_1X_SOURCE_FLL;
266 break;
267
268 default:
269 gk20a_err(dev_from_gk20a(g),
270 "invalid source %d", prog_type);
271 status = -EINVAL;
272 goto done;
273 }
274
275 prog_data.v1x.freq_max_mhz = (u16)prog.freq_max_mhz;
276
277 prog_type = (u8)BIOS_GET_FIELD(prog.flags0,
278 NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE);
279
280 vfentry = entry + szfmt +
281 header.slave_entry_count * slaveszfmt;
282 slaveentry = entry + szfmt;
283 switch (prog_type) {
284 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_MASTER_RATIO:
285 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_MASTER_TABLE:
286 prog_data.v1x_master.b_o_c_o_v_enabled = false;
287 for (j = 0; j < header.vf_entry_count; j++) {
288 memcpy(&vfprog, vfentry, vfszfmt);
289
290 vfentries[j].vfe_idx = (u8)vfprog.vfe_idx;
291 if (CTRL_CLK_PROG_1X_SOURCE_FLL ==
292 prog_data.v1x.source) {
293 vfentries[j].gain_vfe_idx = (u8)BIOS_GET_FIELD(
294 vfprog.param0,
295 NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_VF_ENTRY_PARAM0_FLL_GAIN_VFE_IDX);
296 } else {
297 vfentries[j].gain_vfe_idx = CTRL_BOARDOBJ_IDX_INVALID;
298 }
299 vfentry += vfszfmt;
300 }
301
302 prog_data.v1x_master.p_vf_entries = vfentries;
303
304 for (j = 0; j < header.slave_entry_count; j++) {
305 memcpy(&slaveprog, slaveentry, slaveszfmt);
306
307 switch (prog_type) {
308 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_MASTER_RATIO:
309 ratioslaveentries[j].clk_dom_idx =
310 (u8)slaveprog.clk_dom_idx;
311 ratioslaveentries[j].ratio = (u8)
312 BIOS_GET_FIELD(slaveprog.param0,
313 NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_SLAVE_ENTRY_PARAM0_MASTER_RATIO_RATIO);
314 break;
315
316 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_MASTER_TABLE:
317 tableslaveentries[j].clk_dom_idx =
318 (u8)slaveprog.clk_dom_idx;
319 tableslaveentries[j].freq_mhz =
320 (u16)BIOS_GET_FIELD(slaveprog.param0,
321 NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_SLAVE_ENTRY_PARAM0_MASTER_TABLE_FREQ);
322 break;
323 }
324 slaveentry += slaveszfmt;
325 }
326
327 switch (prog_type) {
328 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_MASTER_RATIO:
329 prog_data.board_obj.type = CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO;
330 prog_data.v1x_master_ratio.p_slave_entries =
331 ratioslaveentries;
332 break;
333
334 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_MASTER_TABLE:
335 prog_data.board_obj.type = CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_TABLE;
336
337 prog_data.v1x_master_table.p_slave_entries =
338 tableslaveentries;
339 break;
340
341 }
342 break;
343
344 case NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_SLAVE:
345 prog_data.board_obj.type = CTRL_CLK_CLK_PROG_TYPE_1X;
346 break;
347
348
349 default:
350 gk20a_err(dev_from_gk20a(g),
351 "source issue %d", prog_type);
352 status = -EINVAL;
353 goto done;
354 }
355
356 pprog = construct_clk_prog(g, (void *)&prog_data);
357 if (pprog == NULL) {
358 gk20a_err(dev_from_gk20a(g),
359 "error constructing clk_prog boardobj %d", i);
360 status = -EINVAL;
361 goto done;
362 }
363
364 status = boardobjgrp_objinsert(&pclkprogobjs->super.super,
365 (struct boardobj *)pprog, i);
366 if (status) {
367 gk20a_err(dev_from_gk20a(g),
368 "error adding clk_prog boardobj %d", i);
369 status = -EINVAL;
370 goto done;
371 }
372 }
373done:
374 gk20a_dbg_info(" done status %x", status);
375 return status;
376}
377
378static u32 _clk_prog_pmudatainit_super(struct gk20a *g,
379 struct boardobj *board_obj_ptr,
380 struct nv_pmu_boardobj *ppmudata)
381{
382 u32 status = 0;
383
384 gk20a_dbg_info("");
385
386 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
387 return status;
388}
389
390static u32 _clk_prog_pmudatainit_1x(struct gk20a *g,
391 struct boardobj *board_obj_ptr,
392 struct nv_pmu_boardobj *ppmudata)
393{
394 u32 status = 0;
395 struct clk_prog_1x *pclk_prog_1x;
396 struct nv_pmu_clk_clk_prog_1x_boardobj_set *pset;
397
398 gk20a_dbg_info("");
399
400 status = _clk_prog_pmudatainit_super(g, board_obj_ptr, ppmudata);
401 if (status != 0)
402 return status;
403
404 pclk_prog_1x = (struct clk_prog_1x *)board_obj_ptr;
405
406 pset = (struct nv_pmu_clk_clk_prog_1x_boardobj_set *)
407 ppmudata;
408
409 pset->source = pclk_prog_1x->source;
410 pset->freq_max_mhz = pclk_prog_1x->freq_max_mhz;
411 pset->source_data = pclk_prog_1x->source_data;
412
413 return status;
414}
415
416static u32 _clk_prog_pmudatainit_1x_master(struct gk20a *g,
417 struct boardobj *board_obj_ptr,
418 struct nv_pmu_boardobj *ppmudata)
419{
420 u32 status = 0;
421 struct clk_prog_1x_master *pclk_prog_1x_master;
422 struct nv_pmu_clk_clk_prog_1x_master_boardobj_set *pset;
423 u32 vfsize = sizeof(struct ctrl_clk_clk_prog_1x_master_vf_entry) *
424 g->clk_pmu.clk_progobjs.vf_entry_count;
425
426 gk20a_dbg_info("");
427
428 status = _clk_prog_pmudatainit_1x(g, board_obj_ptr, ppmudata);
429
430 pclk_prog_1x_master =
431 (struct clk_prog_1x_master *)board_obj_ptr;
432
433 pset = (struct nv_pmu_clk_clk_prog_1x_master_boardobj_set *)
434 ppmudata;
435
436 memcpy(pset->vf_entries, pclk_prog_1x_master->p_vf_entries, vfsize);
437
438 pset->b_o_c_o_v_enabled = pclk_prog_1x_master->b_o_c_o_v_enabled;
439 pset->source_data = pclk_prog_1x_master->source_data;
440
441 memcpy(&pset->deltas, &pclk_prog_1x_master->deltas,
442 (u32) sizeof(struct ctrl_clk_clk_delta));
443
444 return status;
445}
446
447static u32 _clk_prog_pmudatainit_1x_master_ratio(struct gk20a *g,
448 struct boardobj *board_obj_ptr,
449 struct nv_pmu_boardobj *ppmudata)
450{
451 u32 status = 0;
452 struct clk_prog_1x_master_ratio *pclk_prog_1x_master_ratio;
453 struct nv_pmu_clk_clk_prog_1x_master_ratio_boardobj_set *pset;
454 u32 slavesize = sizeof(struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry) *
455 g->clk_pmu.clk_progobjs.slave_entry_count;
456
457 gk20a_dbg_info("");
458
459 status = _clk_prog_pmudatainit_1x_master(g, board_obj_ptr, ppmudata);
460 if (status != 0)
461 return status;
462
463 pclk_prog_1x_master_ratio =
464 (struct clk_prog_1x_master_ratio *)board_obj_ptr;
465
466 pset = (struct nv_pmu_clk_clk_prog_1x_master_ratio_boardobj_set *)
467 ppmudata;
468
469 memcpy(pset->slave_entries,
470 pclk_prog_1x_master_ratio->p_slave_entries, slavesize);
471
472 return status;
473}
474
475static u32 _clk_prog_pmudatainit_1x_master_table(struct gk20a *g,
476 struct boardobj *board_obj_ptr,
477 struct nv_pmu_boardobj *ppmudata)
478{
479 u32 status = 0;
480 struct clk_prog_1x_master_table *pclk_prog_1x_master_table;
481 struct nv_pmu_clk_clk_prog_1x_master_table_boardobj_set *pset;
482 u32 slavesize = sizeof(struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry) *
483 g->clk_pmu.clk_progobjs.slave_entry_count;
484
485 gk20a_dbg_info("");
486
487 status = _clk_prog_pmudatainit_1x_master(g, board_obj_ptr, ppmudata);
488 if (status != 0)
489 return status;
490
491 pclk_prog_1x_master_table =
492 (struct clk_prog_1x_master_table *)board_obj_ptr;
493
494 pset = (struct nv_pmu_clk_clk_prog_1x_master_table_boardobj_set *)
495 ppmudata;
496 memcpy(pset->slave_entries,
497 pclk_prog_1x_master_table->p_slave_entries, slavesize);
498
499 return status;
500}
501
502static u32 _clk_prog_1x_master_rail_construct_vf_point(struct gk20a *g,
503 struct clk_pmupstate *pclk,
504 struct clk_prog_1x_master *p1xmaster,
505 struct ctrl_clk_clk_prog_1x_master_vf_entry *p_vf_rail,
506 struct clk_vf_point *p_vf_point_tmp,
507 u8 *p_vf_point_idx)
508{
509 struct clk_vf_point *p_vf_point;
510 u32 status;
511
512 gk20a_dbg_info("");
513
514 p_vf_point = construct_clk_vf_point(g, (void *)p_vf_point_tmp);
515 if (p_vf_point == NULL) {
516 status = -ENOMEM;
517 goto done;
518 }
519 status = pclk->clk_vf_pointobjs.super.super.objinsert(
520 &pclk->clk_vf_pointobjs.super.super,
521 &p_vf_point->super,
522 *p_vf_point_idx);
523 if (status)
524 goto done;
525
526 p_vf_rail->vf_point_idx_last = (*p_vf_point_idx)++;
527
528done:
529 gk20a_dbg_info("done status %x", status);
530 return status;
531}
532
533static u32 clk_prog_construct_super(struct gk20a *g,
534 struct boardobj **ppboardobj,
535 u16 size, void *pargs)
536{
537 struct clk_prog *pclkprog;
538 u32 status = 0;
539
540 status = boardobj_construct_super(g, ppboardobj,
541 size, pargs);
542 if (status)
543 return -EINVAL;
544
545 pclkprog = (struct clk_prog *)*ppboardobj;
546
547 pclkprog->super.pmudatainit =
548 _clk_prog_pmudatainit_super;
549 return status;
550}
551
552
553static u32 clk_prog_construct_1x(struct gk20a *g,
554 struct boardobj **ppboardobj,
555 u16 size, void *pargs)
556{
557 struct boardobj *ptmpobj = (struct boardobj *)pargs;
558 struct clk_prog_1x *pclkprog;
559 struct clk_prog_1x *ptmpprog =
560 (struct clk_prog_1x *)pargs;
561 u32 status = 0;
562
563 gk20a_dbg_info(" ");
564 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X);
565 status = clk_prog_construct_super(g, ppboardobj, size, pargs);
566 if (status)
567 return -EINVAL;
568
569 pclkprog = (struct clk_prog_1x *)*ppboardobj;
570
571 pclkprog->super.super.pmudatainit =
572 _clk_prog_pmudatainit_1x;
573
574 pclkprog->source = ptmpprog->source;
575 pclkprog->freq_max_mhz = ptmpprog->freq_max_mhz;
576 pclkprog->source_data = ptmpprog->source_data;
577
578 return status;
579}
580
581static u32 clk_prog_construct_1x_master(struct gk20a *g,
582 struct boardobj **ppboardobj,
583 u16 size, void *pargs)
584{
585 struct boardobj *ptmpobj = (struct boardobj *)pargs;
586 struct clk_prog_1x_master *pclkprog;
587 struct clk_prog_1x_master *ptmpprog =
588 (struct clk_prog_1x_master *)pargs;
589 u32 status = 0;
590 u32 vfsize = sizeof(struct ctrl_clk_clk_prog_1x_master_vf_entry) *
591 g->clk_pmu.clk_progobjs.vf_entry_count;
592 u8 railidx;
593
594 gk20a_dbg_info(" type - %x", BOARDOBJ_GET_TYPE(pargs));
595
596 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X_MASTER);
597 status = clk_prog_construct_1x(g, ppboardobj, size, pargs);
598 if (status)
599 return -EINVAL;
600
601 pclkprog = (struct clk_prog_1x_master *)*ppboardobj;
602
603 pclkprog->super.super.super.pmudatainit =
604 _clk_prog_pmudatainit_1x_master;
605
606 pclkprog->vfflatten =
607 vfflatten_prog_1x_master;
608
609 pclkprog->vflookup =
610 vflookup_prog_1x_master;
611
612 pclkprog->getfpoints =
613 getfpoints_prog_1x_master;
614
615 pclkprog->getslaveclk =
616 getslaveclk_prog_1x_master;
617
618 pclkprog->p_vf_entries = (struct ctrl_clk_clk_prog_1x_master_vf_entry *)
619 kzalloc(vfsize, GFP_KERNEL);
620
621 memcpy(pclkprog->p_vf_entries, ptmpprog->p_vf_entries, vfsize);
622
623 pclkprog->b_o_c_o_v_enabled = ptmpprog->b_o_c_o_v_enabled;
624
625 for (railidx = 0;
626 railidx < g->clk_pmu.clk_progobjs.vf_entry_count;
627 railidx++) {
628 pclkprog->p_vf_entries[railidx].vf_point_idx_first =
629 CTRL_CLK_CLK_VF_POINT_IDX_INVALID;
630 pclkprog->p_vf_entries[railidx].vf_point_idx_last =
631 CTRL_CLK_CLK_VF_POINT_IDX_INVALID;
632 }
633
634 return status;
635}
636
637static u32 clk_prog_construct_1x_master_ratio(struct gk20a *g,
638 struct boardobj **ppboardobj,
639 u16 size, void *pargs)
640{
641 struct boardobj *ptmpobj = (struct boardobj *)pargs;
642 struct clk_prog_1x_master_ratio *pclkprog;
643 struct clk_prog_1x_master_ratio *ptmpprog =
644 (struct clk_prog_1x_master_ratio *)pargs;
645 u32 status = 0;
646 u32 slavesize = sizeof(struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry) *
647 g->clk_pmu.clk_progobjs.slave_entry_count;
648
649 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO)
650 return -EINVAL;
651
652 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO);
653 status = clk_prog_construct_1x_master(g, ppboardobj, size, pargs);
654 if (status)
655 return -EINVAL;
656
657 pclkprog = (struct clk_prog_1x_master_ratio *)*ppboardobj;
658
659 pclkprog->super.super.super.super.pmudatainit =
660 _clk_prog_pmudatainit_1x_master_ratio;
661
662 pclkprog->p_slave_entries =
663 (struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *)
664 kzalloc(slavesize, GFP_KERNEL);
665 if (!pclkprog->p_slave_entries)
666 return -ENOMEM;
667
668 memset(pclkprog->p_slave_entries, CTRL_CLK_CLK_DOMAIN_INDEX_INVALID,
669 slavesize);
670
671 memcpy(pclkprog->p_slave_entries, ptmpprog->p_slave_entries, slavesize);
672
673 return status;
674}
675
676static u32 clk_prog_construct_1x_master_table(struct gk20a *g,
677 struct boardobj **ppboardobj,
678 u16 size, void *pargs)
679{
680 struct boardobj *ptmpobj = (struct boardobj *)pargs;
681 struct clk_prog_1x_master_table *pclkprog;
682 struct clk_prog_1x_master_table *ptmpprog =
683 (struct clk_prog_1x_master_table *)pargs;
684 u32 status = 0;
685 u32 slavesize = sizeof(struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry) *
686 g->clk_pmu.clk_progobjs.slave_entry_count;
687
688 gk20a_dbg_info("type - %x", BOARDOBJ_GET_TYPE(pargs));
689
690 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_TABLE)
691 return -EINVAL;
692
693 ptmpobj->type_mask |= BIT(CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_TABLE);
694 status = clk_prog_construct_1x_master(g, ppboardobj, size, pargs);
695 if (status)
696 return -EINVAL;
697
698 pclkprog = (struct clk_prog_1x_master_table *)*ppboardobj;
699
700 pclkprog->super.super.super.super.pmudatainit =
701 _clk_prog_pmudatainit_1x_master_table;
702
703 pclkprog->p_slave_entries =
704 (struct ctrl_clk_clk_prog_1x_master_table_slave_entry *)
705 kzalloc(slavesize, GFP_KERNEL);
706 if (!pclkprog->p_slave_entries)
707 return -ENOMEM;
708
709 memset(pclkprog->p_slave_entries, CTRL_CLK_CLK_DOMAIN_INDEX_INVALID,
710 slavesize);
711
712 memcpy(pclkprog->p_slave_entries, ptmpprog->p_slave_entries, slavesize);
713
714 return status;
715}
716
717static struct clk_prog *construct_clk_prog(struct gk20a *g, void *pargs)
718{
719 struct boardobj *board_obj_ptr = NULL;
720 u32 status;
721
722 gk20a_dbg_info(" type - %x", BOARDOBJ_GET_TYPE(pargs));
723 switch (BOARDOBJ_GET_TYPE(pargs)) {
724 case CTRL_CLK_CLK_PROG_TYPE_1X:
725 status = clk_prog_construct_1x(g, &board_obj_ptr,
726 sizeof(struct clk_prog_1x), pargs);
727 break;
728
729 case CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_TABLE:
730 status = clk_prog_construct_1x_master_table(g, &board_obj_ptr,
731 sizeof(struct clk_prog_1x_master_table), pargs);
732 break;
733
734 case CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO:
735 status = clk_prog_construct_1x_master_ratio(g, &board_obj_ptr,
736 sizeof(struct clk_prog_1x_master_ratio), pargs);
737 break;
738
739 default:
740 return NULL;
741 }
742
743 if (status)
744 return NULL;
745
746 gk20a_dbg_info(" Done");
747
748 return (struct clk_prog *)board_obj_ptr;
749}
750
751static u32 vfflatten_prog_1x_master(struct gk20a *g,
752 struct clk_pmupstate *pclk,
753 struct clk_prog_1x_master *p1xmaster,
754 u8 clk_domain_idx, u16 *pfreqmaxlastmhz)
755{
756 struct ctrl_clk_clk_prog_1x_master_vf_entry *p_vf_rail;
757 union {
758 struct boardobj board_obj;
759 struct clk_vf_point vf_point;
760 struct clk_vf_point_freq freq;
761 struct clk_vf_point_volt volt;
762 } vf_point_data;
763 u32 status = 0;
764 u8 step_count;
765 u8 freq_step_size_mhz = 0;
766 u8 vf_point_idx;
767 u8 vf_rail_idx;
768
769 gk20a_dbg_info("");
770 memset(&vf_point_data, 0x0, sizeof(vf_point_data));
771
772 vf_point_idx = BOARDOBJGRP_NEXT_EMPTY_IDX(
773 &pclk->clk_vf_pointobjs.super.super);
774
775 for (vf_rail_idx = 0;
776 vf_rail_idx < pclk->clk_progobjs.vf_entry_count;
777 vf_rail_idx++) {
778 u32 voltage_min_uv;
779 u32 voltage_step_size_uv;
780 u8 i;
781
782 p_vf_rail = &p1xmaster->p_vf_entries[vf_rail_idx];
783 if (p_vf_rail->vfe_idx == CTRL_BOARDOBJ_IDX_INVALID)
784 continue;
785
786 p_vf_rail->vf_point_idx_first = vf_point_idx;
787
788 vf_point_data.vf_point.vfe_equ_idx = p_vf_rail->vfe_idx;
789 vf_point_data.vf_point.volt_rail_idx = vf_rail_idx;
790
791 step_count = 0;
792
793 switch (p1xmaster->super.source) {
794 case CTRL_CLK_PROG_1X_SOURCE_PLL:
795 freq_step_size_mhz =
796 p1xmaster->super.source_data.pll.freq_step_size_mhz;
797 step_count = (freq_step_size_mhz == 0) ? 0 :
798 (p1xmaster->super.freq_max_mhz - *pfreqmaxlastmhz - 1) /
799 freq_step_size_mhz;
800 /* Intentional fall-through.*/
801
802 case CTRL_CLK_PROG_1X_SOURCE_ONE_SOURCE:
803 vf_point_data.board_obj.type =
804 CTRL_CLK_CLK_VF_POINT_TYPE_FREQ;
805 do {
806 clkvfpointfreqmhzset(g, &vf_point_data.vf_point,
807 p1xmaster->super.freq_max_mhz -
808 step_count * freq_step_size_mhz);
809
810 status = _clk_prog_1x_master_rail_construct_vf_point(g, pclk,
811 p1xmaster, p_vf_rail,
812 &vf_point_data.vf_point, &vf_point_idx);
813 if (status)
814 goto done;
815 } while (step_count-- > 0);
816 break;
817
818 case CTRL_CLK_PROG_1X_SOURCE_FLL:
819 voltage_min_uv = CLK_FLL_LUT_MIN_VOLTAGE_UV(pclk);
820 voltage_step_size_uv = CLK_FLL_LUT_STEP_SIZE_UV(pclk);
821 step_count = CLK_FLL_LUT_VF_NUM_ENTRIES(pclk);
822
823 /* FLL sources use a voltage-based VF_POINT.*/
824 vf_point_data.board_obj.type =
825 CTRL_CLK_CLK_VF_POINT_TYPE_VOLT;
826 for (i = 0; i < step_count; i++) {
827 vf_point_data.volt.source_voltage_uv =
828 voltage_min_uv + i * voltage_step_size_uv;
829
830 status = _clk_prog_1x_master_rail_construct_vf_point(g, pclk,
831 p1xmaster, p_vf_rail,
832 &vf_point_data.vf_point, &vf_point_idx);
833 if (status)
834 goto done;
835 }
836 break;
837 }
838 }
839
840 *pfreqmaxlastmhz = p1xmaster->super.freq_max_mhz;
841
842done:
843 gk20a_dbg_info("done status %x", status);
844 return status;
845}
846
847static u32 vflookup_prog_1x_master
848(
849 struct gk20a *g,
850 struct clk_pmupstate *pclk,
851 struct clk_prog_1x_master *p1xmaster,
852 u8 *slave_clk_domain,
853 u16 *pclkmhz,
854 u32 *pvoltuv,
855 u8 rail
856)
857{
858 int j;
859 struct ctrl_clk_clk_prog_1x_master_vf_entry
860 *pvfentry;
861 struct clk_vf_point *pvfpoint;
862 struct clk_progs *pclkprogobjs;
863 struct clk_prog_1x_master_ratio *p1xmasterratio;
864 u16 clkmhz;
865 u32 voltuv;
866 u8 slaveentrycount;
867 int i;
868 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *pslaveents;
869
870 if ((*pclkmhz != 0) && (*pvoltuv != 0))
871 return -EINVAL;
872
873 pclkprogobjs = &(pclk->clk_progobjs);
874
875 slaveentrycount = pclkprogobjs->slave_entry_count;
876
877 if (pclkprogobjs->vf_entry_count >
878 CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES)
879 return -EINVAL;
880
881 if (rail >= pclkprogobjs->vf_entry_count)
882 return -EINVAL;
883
884 pvfentry = p1xmaster->p_vf_entries;
885
886 pvfentry = (struct ctrl_clk_clk_prog_1x_master_vf_entry *)(
887 (u8 *)pvfentry +
888 (sizeof(struct ctrl_clk_clk_prog_1x_master_vf_entry) *
889 rail));
890
891 clkmhz = *pclkmhz;
892 voltuv = *pvoltuv;
893
894 /*if domain is slave domain and freq is input
895 then derive master clk */
896 if ((slave_clk_domain != NULL) && (*pclkmhz != 0)) {
897 if (p1xmaster->super.super.super.implements(g,
898 &p1xmaster->super.super.super,
899 CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO)) {
900
901 p1xmasterratio =
902 (struct clk_prog_1x_master_ratio *)p1xmaster;
903 pslaveents = p1xmasterratio->p_slave_entries;
904 for (i = 0; i < slaveentrycount; i++) {
905 if (pslaveents->clk_dom_idx ==
906 *slave_clk_domain)
907 break;
908 pslaveents++;
909 }
910 if (i == slaveentrycount)
911 return -EINVAL;
912 clkmhz = (clkmhz * 100)/pslaveents->ratio;
913 } else {
914 /* only support ratio for now */
915 return -EINVAL;
916 }
917 }
918
919 /* if both volt and clks are zero simply print*/
920 if ((*pvoltuv == 0) && (*pclkmhz == 0)) {
921 for (j = pvfentry->vf_point_idx_first;
922 j <= pvfentry->vf_point_idx_last; j++) {
923 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j);
924 gk20a_err(dev_from_gk20a(g), "v %x c %x",
925 clkvfpointvoltageuvget(g, pvfpoint),
926 clkvfpointfreqmhzget(g, pvfpoint));
927 }
928 return -EINVAL;
929 }
930 /* start looking up f for v for v for f */
931 /* looking for volt? */
932 if (*pvoltuv == 0) {
933 pvfpoint = CLK_CLK_VF_POINT_GET(pclk,
934 pvfentry->vf_point_idx_last);
935 /* above range? */
936 if (clkmhz > clkvfpointfreqmhzget(g, pvfpoint))
937 return -EINVAL;
938
939 for (j = pvfentry->vf_point_idx_last;
940 j >= pvfentry->vf_point_idx_first; j--) {
941 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j);
942 if (clkmhz <= clkvfpointfreqmhzget(g, pvfpoint))
943 voltuv = clkvfpointvoltageuvget(g, pvfpoint);
944 else
945 break;
946 }
947 } else { /* looking for clk? */
948
949 pvfpoint = CLK_CLK_VF_POINT_GET(pclk,
950 pvfentry->vf_point_idx_first);
951 /* below range? */
952 if (voltuv < clkvfpointvoltageuvget(g, pvfpoint))
953 return -EINVAL;
954
955 for (j = pvfentry->vf_point_idx_first;
956 j <= pvfentry->vf_point_idx_last; j++) {
957 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j);
958 if (voltuv >= clkvfpointvoltageuvget(g, pvfpoint))
959 clkmhz = clkvfpointfreqmhzget(g, pvfpoint);
960 else
961 break;
962 }
963 }
964
965 /*if domain is slave domain and freq was looked up
966 then derive slave clk */
967 if ((slave_clk_domain != NULL) && (*pclkmhz == 0)) {
968 if (p1xmaster->super.super.super.implements(g,
969 &p1xmaster->super.super.super,
970 CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO)) {
971
972 p1xmasterratio =
973 (struct clk_prog_1x_master_ratio *)p1xmaster;
974 pslaveents = p1xmasterratio->p_slave_entries;
975 for (i = 0; i < slaveentrycount; i++) {
976 if (pslaveents->clk_dom_idx ==
977 *slave_clk_domain)
978 break;
979 pslaveents++;
980 }
981 if (i == slaveentrycount)
982 return -EINVAL;
983 clkmhz = (clkmhz * pslaveents->ratio)/100;
984 } else {
985 /* only support ratio for now */
986 return -EINVAL;
987 }
988 }
989 *pclkmhz = clkmhz;
990 *pvoltuv = voltuv;
991 if ((clkmhz == 0) || (voltuv == 0))
992 return -EINVAL;
993 return 0;
994}
995
996static u32 getfpoints_prog_1x_master
997(
998 struct gk20a *g,
999 struct clk_pmupstate *pclk,
1000 struct clk_prog_1x_master *p1xmaster,
1001 u32 *pfpointscount,
1002 u16 **ppfreqpointsinmhz,
1003 u8 rail
1004)
1005{
1006
1007 struct ctrl_clk_clk_prog_1x_master_vf_entry
1008 *pvfentry;
1009 struct clk_vf_point *pvfpoint;
1010 struct clk_progs *pclkprogobjs;
1011 u8 j;
1012 u32 fpointscount = 0;
1013
1014 if (pfpointscount == NULL)
1015 return -EINVAL;
1016
1017 pclkprogobjs = &(pclk->clk_progobjs);
1018
1019 if (pclkprogobjs->vf_entry_count >
1020 CTRL_CLK_CLK_PROG_1X_MASTER_VF_ENTRY_MAX_ENTRIES)
1021 return -EINVAL;
1022
1023 if (rail >= pclkprogobjs->vf_entry_count)
1024 return -EINVAL;
1025
1026 pvfentry = p1xmaster->p_vf_entries;
1027
1028 pvfentry = (struct ctrl_clk_clk_prog_1x_master_vf_entry *)(
1029 (u8 *)pvfentry +
1030 (sizeof(struct ctrl_clk_clk_prog_1x_master_vf_entry) *
1031 (rail+1)));
1032
1033 fpointscount = pvfentry->vf_point_idx_last -
1034 pvfentry->vf_point_idx_first + 1;
1035
1036 /* if pointer for freq data is NULL simply return count */
1037 if (*ppfreqpointsinmhz == NULL)
1038 goto done;
1039
1040 if (fpointscount > *pfpointscount)
1041 return -ENOMEM;
1042 for (j = pvfentry->vf_point_idx_first;
1043 j <= pvfentry->vf_point_idx_last; j++) {
1044 pvfpoint = CLK_CLK_VF_POINT_GET(pclk, j);
1045 **ppfreqpointsinmhz = clkvfpointfreqmhzget(g, pvfpoint);
1046 (*ppfreqpointsinmhz)++;
1047 }
1048done:
1049 *pfpointscount = fpointscount;
1050 return 0;
1051}
1052
1053static int getslaveclk_prog_1x_master(struct gk20a *g,
1054 struct clk_pmupstate *pclk,
1055 struct clk_prog_1x_master *p1xmaster,
1056 u8 slave_clk_domain,
1057 u16 *pclkmhz,
1058 u16 masterclkmhz
1059)
1060{
1061 struct clk_progs *pclkprogobjs;
1062 struct clk_prog_1x_master_ratio *p1xmasterratio;
1063 u8 slaveentrycount;
1064 u8 i;
1065 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *pslaveents;
1066
1067 if (pclkmhz == NULL)
1068 return -EINVAL;
1069
1070 if (masterclkmhz == 0)
1071 return -EINVAL;
1072
1073 *pclkmhz = 0;
1074 pclkprogobjs = &(pclk->clk_progobjs);
1075
1076 slaveentrycount = pclkprogobjs->slave_entry_count;
1077
1078 if (p1xmaster->super.super.super.implements(g,
1079 &p1xmaster->super.super.super,
1080 CTRL_CLK_CLK_PROG_TYPE_1X_MASTER_RATIO)) {
1081 p1xmasterratio =
1082 (struct clk_prog_1x_master_ratio *)p1xmaster;
1083 pslaveents = p1xmasterratio->p_slave_entries;
1084 for (i = 0; i < slaveentrycount; i++) {
1085 if (pslaveents->clk_dom_idx ==
1086 slave_clk_domain)
1087 break;
1088 pslaveents++;
1089 }
1090 if (i == slaveentrycount)
1091 return -EINVAL;
1092 *pclkmhz = (masterclkmhz * pslaveents->ratio)/100;
1093 } else {
1094 /* only support ratio for now */
1095 return -EINVAL;
1096 }
1097 return 0;
1098}
diff --git a/drivers/gpu/nvgpu/clk/clk_prog.h b/drivers/gpu/nvgpu/clk/clk_prog.h
new file mode 100644
index 00000000..60711b4c
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_prog.h
@@ -0,0 +1,90 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _CLKPROG_H_
15#define _CLKPROG_H_
16#include "ctrl/ctrlclk.h"
17#include "ctrl/ctrlboardobj.h"
18#include "pmuif/gpmuifclk.h"
19#include "boardobj/boardobjgrp_e32.h"
20#include "boardobj/boardobjgrpmask.h"
21
22u32 clk_prog_sw_setup(struct gk20a *g);
23u32 clk_prog_pmu_setup(struct gk20a *g);
24struct clk_prog_1x_master;
25
26typedef u32 vf_flatten(struct gk20a *g, struct clk_pmupstate *pclk,
27 struct clk_prog_1x_master *p1xmaster,
28 u8 clk_domain_idx, u16 *pfreqmaxlastmhz);
29
30typedef u32 vf_lookup(struct gk20a *g, struct clk_pmupstate *pclk,
31 struct clk_prog_1x_master *p1xmaster,
32 u8 *slave_clk_domain_idx, u16 *pclkmhz,
33 u32 *pvoltuv, u8 rail);
34
35typedef int get_slaveclk(struct gk20a *g, struct clk_pmupstate *pclk,
36 struct clk_prog_1x_master *p1xmaster,
37 u8 slave_clk_domain_idx, u16 *pclkmhz,
38 u16 masterclkmhz);
39
40typedef u32 get_fpoints(struct gk20a *g, struct clk_pmupstate *pclk,
41 struct clk_prog_1x_master *p1xmaster,
42 u32 *pfpointscount,
43 u16 **ppfreqpointsinmhz, u8 rail);
44
45
46struct clk_progs {
47 struct boardobjgrp_e255 super;
48 u8 slave_entry_count;
49 u8 vf_entry_count;
50
51};
52
53struct clk_prog {
54 struct boardobj super;
55};
56
57struct clk_prog_1x {
58 struct clk_prog super;
59 u8 source;
60 u16 freq_max_mhz;
61 union ctrl_clk_clk_prog_1x_source_data source_data;
62};
63
64struct clk_prog_1x_master {
65 struct clk_prog_1x super;
66 bool b_o_c_o_v_enabled;
67 struct ctrl_clk_clk_prog_1x_master_vf_entry *p_vf_entries;
68 struct ctrl_clk_clk_delta deltas;
69 union ctrl_clk_clk_prog_1x_master_source_data source_data;
70 vf_flatten *vfflatten;
71 vf_lookup *vflookup;
72 get_fpoints *getfpoints;
73 get_slaveclk *getslaveclk;
74};
75
76struct clk_prog_1x_master_ratio {
77 struct clk_prog_1x_master super;
78 struct ctrl_clk_clk_prog_1x_master_ratio_slave_entry *p_slave_entries;
79};
80
81struct clk_prog_1x_master_table {
82 struct clk_prog_1x_master super;
83 struct ctrl_clk_clk_prog_1x_master_table_slave_entry *p_slave_entries;
84};
85
86#define CLK_CLK_PROG_GET(pclk, idx) \
87 ((struct clk_prog *)BOARDOBJGRP_OBJ_GET_BY_IDX( \
88 &pclk->clk_progobjs.super.super, (u8)(idx)))
89
90#endif
diff --git a/drivers/gpu/nvgpu/clk/clk_vf_point.c b/drivers/gpu/nvgpu/clk/clk_vf_point.c
new file mode 100644
index 00000000..4fde7226
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_vf_point.c
@@ -0,0 +1,418 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "clk.h"
16#include "clk_vf_point.h"
17#include "include/bios.h"
18#include "boardobj/boardobjgrp.h"
19#include "boardobj/boardobjgrp_e32.h"
20#include "pmuif/gpmuifboardobj.h"
21#include "pmuif/gpmuifclk.h"
22#include "gm206/bios_gm206.h"
23#include "ctrl/ctrlclk.h"
24#include "ctrl/ctrlvolt.h"
25#include "gk20a/pmu_gk20a.h"
26
27static u32 _clk_vf_point_pmudatainit_super(struct gk20a *g, struct boardobj
28 *board_obj_ptr, struct nv_pmu_boardobj *ppmudata);
29
30static u32 _clk_vf_points_pmudatainit(struct gk20a *g,
31 struct boardobjgrp *pboardobjgrp,
32 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu)
33{
34 u32 status = 0;
35
36 status = boardobjgrp_pmudatainit_e32(g, pboardobjgrp, pboardobjgrppmu);
37 if (status) {
38 gk20a_err(dev_from_gk20a(g),
39 "error updating pmu boardobjgrp for clk vfpoint 0x%x",
40 status);
41 goto done;
42 }
43
44done:
45 return status;
46}
47
48static u32 _clk_vf_points_pmudata_instget(struct gk20a *g,
49 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
50 struct nv_pmu_boardobj **ppboardobjpmudata,
51 u8 idx)
52{
53 struct nv_pmu_clk_clk_vf_point_boardobj_grp_set *pgrp_set =
54 (struct nv_pmu_clk_clk_vf_point_boardobj_grp_set *)
55 pmuboardobjgrp;
56
57 gk20a_dbg_info("");
58
59 /*check whether pmuboardobjgrp has a valid boardobj in index*/
60 if (idx >= CTRL_BOARDOBJGRP_E255_MAX_OBJECTS)
61 return -EINVAL;
62
63 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
64 &pgrp_set->objects[idx].data.board_obj;
65 gk20a_dbg_info(" Done");
66 return 0;
67}
68
69static u32 _clk_vf_points_pmustatus_instget(struct gk20a *g,
70 void *pboardobjgrppmu,
71 struct nv_pmu_boardobj_query **ppboardobjpmustatus,
72 u8 idx)
73{
74 struct nv_pmu_clk_clk_vf_point_boardobj_grp_get_status *pgrp_get_status =
75 (struct nv_pmu_clk_clk_vf_point_boardobj_grp_get_status *)
76 pboardobjgrppmu;
77
78 /*check whether pmuboardobjgrp has a valid boardobj in index*/
79 if (idx >= CTRL_BOARDOBJGRP_E255_MAX_OBJECTS)
80 return -EINVAL;
81
82 *ppboardobjpmustatus = (struct nv_pmu_boardobj_query *)
83 &pgrp_get_status->objects[idx].data.board_obj;
84 return 0;
85}
86
87u32 clk_vf_point_sw_setup(struct gk20a *g)
88{
89 u32 status;
90 struct boardobjgrp *pboardobjgrp = NULL;
91 struct clk_vf_points *pclkvfpointobjs;
92
93 gk20a_dbg_info("");
94
95 status = boardobjgrpconstruct_e255(&g->clk_pmu.clk_vf_pointobjs.super);
96 if (status) {
97 gk20a_err(dev_from_gk20a(g),
98 "error creating boardobjgrp for clk vfpoint, status - 0x%x",
99 status);
100 goto done;
101 }
102
103 pboardobjgrp = &g->clk_pmu.clk_vf_pointobjs.super.super;
104 pclkvfpointobjs = &(g->clk_pmu.clk_vf_pointobjs);
105
106 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, CLK, CLK_VF_POINT);
107
108 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
109 clk, CLK, clk_vf_point, CLK_VF_POINT);
110 if (status) {
111 gk20a_err(dev_from_gk20a(g),
112 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
113 status);
114 goto done;
115 }
116
117 status = BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g,
118 &g->clk_pmu.clk_vf_pointobjs.super.super,
119 clk, CLK, clk_vf_point, CLK_VF_POINT);
120 if (status) {
121 gk20a_err(dev_from_gk20a(g),
122 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
123 status);
124 goto done;
125 }
126
127 pboardobjgrp->pmudatainit = _clk_vf_points_pmudatainit;
128 pboardobjgrp->pmudatainstget = _clk_vf_points_pmudata_instget;
129 pboardobjgrp->pmustatusinstget = _clk_vf_points_pmustatus_instget;
130
131done:
132 gk20a_dbg_info(" done status %x", status);
133 return status;
134}
135
136u32 clk_vf_point_pmu_setup(struct gk20a *g)
137{
138 u32 status;
139 struct boardobjgrp *pboardobjgrp = NULL;
140
141 gk20a_dbg_info("");
142
143 pboardobjgrp = &g->clk_pmu.clk_vf_pointobjs.super.super;
144
145 if (!pboardobjgrp->bconstructed)
146 return -EINVAL;
147
148 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
149
150 gk20a_dbg_info("Done");
151 return status;
152}
153
154static u32 clk_vf_point_construct_super(struct gk20a *g,
155 struct boardobj **ppboardobj,
156 u16 size, void *pargs)
157{
158 struct clk_vf_point *pclkvfpoint;
159 struct clk_vf_point *ptmpvfpoint =
160 (struct clk_vf_point *)pargs;
161 u32 status = 0;
162
163 status = boardobj_construct_super(g, ppboardobj,
164 size, pargs);
165 if (status)
166 return -EINVAL;
167
168 pclkvfpoint = (struct clk_vf_point *)*ppboardobj;
169
170 pclkvfpoint->super.pmudatainit =
171 _clk_vf_point_pmudatainit_super;
172
173 pclkvfpoint->vfe_equ_idx = ptmpvfpoint->vfe_equ_idx;
174 pclkvfpoint->volt_rail_idx = ptmpvfpoint->volt_rail_idx;
175
176 return status;
177}
178
179static u32 _clk_vf_point_pmudatainit_volt(struct gk20a *g,
180 struct boardobj *board_obj_ptr,
181 struct nv_pmu_boardobj *ppmudata)
182{
183 u32 status = 0;
184 struct clk_vf_point_volt *pclk_vf_point_volt;
185 struct nv_pmu_clk_clk_vf_point_volt_boardobj_set *pset;
186
187 gk20a_dbg_info("");
188
189 status = _clk_vf_point_pmudatainit_super(g, board_obj_ptr, ppmudata);
190 if (status != 0)
191 return status;
192
193 pclk_vf_point_volt =
194 (struct clk_vf_point_volt *)board_obj_ptr;
195
196 pset = (struct nv_pmu_clk_clk_vf_point_volt_boardobj_set *)
197 ppmudata;
198
199 pset->source_voltage_uv = pclk_vf_point_volt->source_voltage_uv;
200 pset->freq_delta_khz = pclk_vf_point_volt->freq_delta_khz;
201
202 return status;
203}
204
205static u32 _clk_vf_point_pmudatainit_freq(struct gk20a *g,
206 struct boardobj *board_obj_ptr,
207 struct nv_pmu_boardobj *ppmudata)
208{
209 u32 status = 0;
210 struct clk_vf_point_freq *pclk_vf_point_freq;
211 struct nv_pmu_clk_clk_vf_point_freq_boardobj_set *pset;
212
213 gk20a_dbg_info("");
214
215 status = _clk_vf_point_pmudatainit_super(g, board_obj_ptr, ppmudata);
216 if (status != 0)
217 return status;
218
219 pclk_vf_point_freq =
220 (struct clk_vf_point_freq *)board_obj_ptr;
221
222 pset = (struct nv_pmu_clk_clk_vf_point_freq_boardobj_set *)
223 ppmudata;
224
225 pset->freq_mhz =
226 clkvfpointfreqmhzget(g, &pclk_vf_point_freq->super);
227
228 pset->volt_delta_uv = pclk_vf_point_freq->volt_delta_uv;
229
230 return status;
231}
232
233static u32 clk_vf_point_construct_volt(struct gk20a *g,
234 struct boardobj **ppboardobj,
235 u16 size, void *pargs)
236{
237 struct boardobj *ptmpobj = (struct boardobj *)pargs;
238 struct clk_vf_point_volt *pclkvfpoint;
239 struct clk_vf_point_volt *ptmpvfpoint =
240 (struct clk_vf_point_volt *)pargs;
241 u32 status = 0;
242
243 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_VF_POINT_TYPE_VOLT)
244 return -EINVAL;
245
246 ptmpobj->type_mask = BIT(CTRL_CLK_CLK_VF_POINT_TYPE_VOLT);
247 status = clk_vf_point_construct_super(g, ppboardobj, size, pargs);
248 if (status)
249 return -EINVAL;
250
251 pclkvfpoint = (struct clk_vf_point_volt *)*ppboardobj;
252
253 pclkvfpoint->super.super.pmudatainit =
254 _clk_vf_point_pmudatainit_volt;
255
256 pclkvfpoint->source_voltage_uv = ptmpvfpoint->source_voltage_uv;
257
258 return status;
259}
260
261static u32 clk_vf_point_construct_freq(struct gk20a *g,
262 struct boardobj **ppboardobj,
263 u16 size, void *pargs)
264{
265 struct boardobj *ptmpobj = (struct boardobj *)pargs;
266 struct clk_vf_point_freq *pclkvfpoint;
267 struct clk_vf_point_freq *ptmpvfpoint =
268 (struct clk_vf_point_freq *)pargs;
269 u32 status = 0;
270
271 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_CLK_CLK_VF_POINT_TYPE_FREQ)
272 return -EINVAL;
273
274 ptmpobj->type_mask = BIT(CTRL_CLK_CLK_VF_POINT_TYPE_FREQ);
275 status = clk_vf_point_construct_super(g, ppboardobj, size, pargs);
276 if (status)
277 return -EINVAL;
278
279 pclkvfpoint = (struct clk_vf_point_freq *)*ppboardobj;
280
281 pclkvfpoint->super.super.pmudatainit =
282 _clk_vf_point_pmudatainit_freq;
283
284 clkvfpointfreqmhzset(g, &pclkvfpoint->super,
285 clkvfpointfreqmhzget(g, &ptmpvfpoint->super));
286
287 return status;
288}
289
290struct clk_vf_point *construct_clk_vf_point(struct gk20a *g, void *pargs)
291{
292 struct boardobj *board_obj_ptr = NULL;
293 u32 status;
294
295 gk20a_dbg_info("");
296 switch (BOARDOBJ_GET_TYPE(pargs)) {
297 case CTRL_CLK_CLK_VF_POINT_TYPE_FREQ:
298 status = clk_vf_point_construct_freq(g, &board_obj_ptr,
299 sizeof(struct clk_vf_point_freq), pargs);
300 break;
301
302 case CTRL_CLK_CLK_VF_POINT_TYPE_VOLT:
303 status = clk_vf_point_construct_volt(g, &board_obj_ptr,
304 sizeof(struct clk_vf_point_volt), pargs);
305 break;
306
307 default:
308 return NULL;
309 }
310
311 if (status)
312 return NULL;
313
314 gk20a_dbg_info(" Done");
315
316 return (struct clk_vf_point *)board_obj_ptr;
317}
318
319static u32 _clk_vf_point_pmudatainit_super(struct gk20a *g,
320 struct boardobj *board_obj_ptr,
321 struct nv_pmu_boardobj *ppmudata)
322{
323 u32 status = 0;
324 struct clk_vf_point *pclk_vf_point;
325 struct nv_pmu_clk_clk_vf_point_boardobj_set *pset;
326
327 gk20a_dbg_info("");
328
329 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
330 if (status != 0)
331 return status;
332
333 pclk_vf_point =
334 (struct clk_vf_point *)board_obj_ptr;
335
336 pset = (struct nv_pmu_clk_clk_vf_point_boardobj_set *)
337 ppmudata;
338
339
340 pset->vfe_equ_idx = pclk_vf_point->vfe_equ_idx;
341 pset->volt_rail_idx = pclk_vf_point->volt_rail_idx;
342 return status;
343}
344
345
346static u32 clk_vf_point_update(struct gk20a *g,
347 struct boardobj *board_obj_ptr,
348 struct nv_pmu_boardobj *ppmudata)
349{
350 struct clk_vf_point *pclk_vf_point;
351 struct nv_pmu_clk_clk_vf_point_boardobj_get_status *pstatus;
352
353 gk20a_dbg_info("");
354
355
356 pclk_vf_point =
357 (struct clk_vf_point *)board_obj_ptr;
358
359 pstatus = (struct nv_pmu_clk_clk_vf_point_boardobj_get_status *)
360 ppmudata;
361
362 if (pstatus->super.type != pclk_vf_point->super.type) {
363 gk20a_err(dev_from_gk20a(g),
364 "pmu data and boardobj type not matching");
365 return -EINVAL;
366 }
367 /* now copy VF pair */
368 memcpy(&pclk_vf_point->pair, &pstatus->pair,
369 sizeof(struct ctrl_clk_vf_pair));
370 return 0;
371}
372
373/*get latest vf point data from PMU */
374u32 clk_vf_point_cache(struct gk20a *g)
375{
376
377 struct clk_vf_points *pclk_vf_points;
378 struct boardobjgrp *pboardobjgrp;
379 struct boardobjgrpmask *pboardobjgrpmask;
380 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu;
381 struct boardobj *pboardobj = NULL;
382 struct nv_pmu_boardobj_query *pboardobjpmustatus = NULL;
383 u32 status;
384 u8 index;
385
386 gk20a_dbg_info("");
387 pclk_vf_points = &g->clk_pmu.clk_vf_pointobjs;
388 pboardobjgrp = &pclk_vf_points->super.super;
389 pboardobjgrpmask = &pclk_vf_points->super.mask.super;
390
391 status = pboardobjgrp->pmugetstatus(g, pboardobjgrp, pboardobjgrpmask);
392 if (status) {
393 gk20a_err(dev_from_gk20a(g), "err getting boardobjs from pmu");
394 return status;
395 }
396 pboardobjgrppmu = pboardobjgrp->pmu.getstatus.buf;
397
398 BOARDOBJGRP_FOR_EACH(pboardobjgrp, struct boardobj*, pboardobj, index) {
399 status = pboardobjgrp->pmustatusinstget(g,
400 (struct nv_pmu_boardobjgrp *)pboardobjgrppmu,
401 &pboardobjpmustatus, index);
402 if (status) {
403 gk20a_err(dev_from_gk20a(g),
404 "could not get status object instance");
405 return status;
406 }
407
408 status = clk_vf_point_update(g, pboardobj,
409 (struct nv_pmu_boardobj *)pboardobjpmustatus);
410 if (status) {
411 gk20a_err(dev_from_gk20a(g),
412 "invalid data from pmu at %d", index);
413 return status;
414 }
415 }
416
417 return 0;
418}
diff --git a/drivers/gpu/nvgpu/clk/clk_vf_point.h b/drivers/gpu/nvgpu/clk/clk_vf_point.h
new file mode 100644
index 00000000..15920066
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_vf_point.h
@@ -0,0 +1,74 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _CLKVFPOINT_H_
15#define _CLKVFPOINT_H_
16#include "ctrl/ctrlclk.h"
17#include "ctrl/ctrlboardobj.h"
18#include "pmuif/gpmuifclk.h"
19#include "boardobj/boardobjgrp_e32.h"
20#include "boardobj/boardobjgrpmask.h"
21
22u32 clk_vf_point_sw_setup(struct gk20a *g);
23u32 clk_vf_point_pmu_setup(struct gk20a *g);
24u32 clk_vf_point_cache(struct gk20a *g);
25
26struct clk_vf_points {
27 struct boardobjgrp_e255 super;
28};
29
30struct clk_vf_point {
31 struct boardobj super;
32 u8 vfe_equ_idx;
33 u8 volt_rail_idx;
34 struct ctrl_clk_vf_pair pair;
35};
36
37struct clk_vf_point_volt {
38 struct clk_vf_point super;
39 u32 source_voltage_uv;
40 int freq_delta_khz;
41};
42
43struct clk_vf_point_freq {
44 struct clk_vf_point super;
45 int volt_delta_uv;
46};
47
48#define CLK_CLK_VF_POINT_GET(pclk, idx) \
49 ((struct clk_vf_point *)BOARDOBJGRP_OBJ_GET_BY_IDX( \
50 &pclk->clk_vf_pointobjs.super.super, (u8)(idx)))
51
52#define clkvfpointpairget(pvfpoint) \
53 (&((pvfpoint)->pair))
54
55#define clkvfpointfreqmhzget(pgpu, pvfpoint) \
56 CTRL_CLK_VF_PAIR_FREQ_MHZ_GET(clkvfpointpairget(pvfpoint))
57
58#define clkvfpointfreqdeltamhzGet(pgpu, pvfPoint) \
59 ((BOARDOBJ_GET_TYPE(pvfpoint) == CTRL_CLK_CLK_VF_POINT_TYPE_VOLT) ? \
60 (((struct clk_vf_point_volt *)(pvfpoint))->freq_delta_khz / 1000) : 0)
61
62#define clkvfpointfreqmhzset(pgpu, pvfpoint, _freqmhz) \
63 CTRL_CLK_VF_PAIR_FREQ_MHZ_SET(clkvfpointpairget(pvfpoint), _freqmhz)
64
65#define clkvfpointvoltageuvset(pgpu, pvfpoint, _voltageuv) \
66 CTRL_CLK_VF_PAIR_VOLTAGE_UV_SET(clkvfpointpairget(pvfpoint), \
67 _voltageuv)
68
69#define clkvfpointvoltageuvget(pgpu, pvfpoint) \
70 CTRL_CLK_VF_PAIR_VOLTAGE_UV_GET(clkvfpointpairget(pvfpoint)) \
71
72struct clk_vf_point *construct_clk_vf_point(struct gk20a *g, void *pargs);
73
74#endif
diff --git a/drivers/gpu/nvgpu/clk/clk_vin.c b/drivers/gpu/nvgpu/clk/clk_vin.c
new file mode 100644
index 00000000..e8e4b753
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_vin.c
@@ -0,0 +1,466 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "clk.h"
16#include "clk_vin.h"
17#include "include/bios.h"
18#include "boardobj/boardobjgrp.h"
19#include "boardobj/boardobjgrp_e32.h"
20#include "pmuif/gpmuifboardobj.h"
21#include "pmuif/gpmuifclk.h"
22#include "gm206/bios_gm206.h"
23#include "ctrl/ctrlvolt.h"
24#include "gk20a/pmu_gk20a.h"
25#include "gp106/hw_fuse_gp106.h"
26
27static u32 devinit_get_vin_device_table(struct gk20a *g,
28 struct avfsvinobjs *pvinobjs);
29
30static struct vin_device *construct_vin_device(struct gk20a *g, void *pargs);
31
32static u32 vin_device_init_pmudata_super(struct gk20a *g,
33 struct boardobj *board_obj_ptr,
34 struct nv_pmu_boardobj *ppmudata);
35
36static u32 read_vin_cal_fuse_rev(struct gk20a *g)
37{
38 return fuse_vin_cal_fuse_rev_v(
39 gk20a_readl(g, fuse_vin_cal_fuse_rev_r()));
40}
41
42static u32 read_vin_cal_slope_intercept_fuse(struct gk20a *g,
43 u32 vin_id, u32 *slope,
44 u32 *intercept)
45{
46 u32 data = 0;
47 u32 interceptdata = 0;
48 u32 slopedata = 0;
49 u32 gpc0data;
50 u32 gpc0slopedata;
51 u32 gpc0interceptdata;
52
53 /* read gpc0 irrespective of vin id */
54 gpc0data = gk20a_readl(g, fuse_vin_cal_gpc0_r());
55 if (gpc0data == 0xFFFFFFFF)
56 return -EINVAL;
57
58 switch (vin_id) {
59 case CTRL_CLK_VIN_ID_GPC0:
60 break;
61
62 case CTRL_CLK_VIN_ID_GPC1:
63 data = gk20a_readl(g, fuse_vin_cal_gpc1_delta_r());
64 break;
65
66 case CTRL_CLK_VIN_ID_GPC2:
67 data = gk20a_readl(g, fuse_vin_cal_gpc2_delta_r());
68 break;
69
70 case CTRL_CLK_VIN_ID_GPC3:
71 data = gk20a_readl(g, fuse_vin_cal_gpc3_delta_r());
72 break;
73
74 case CTRL_CLK_VIN_ID_GPC4:
75 data = gk20a_readl(g, fuse_vin_cal_gpc4_delta_r());
76 break;
77
78 case CTRL_CLK_VIN_ID_GPC5:
79 data = gk20a_readl(g, fuse_vin_cal_gpc5_delta_r());
80 break;
81
82 case CTRL_CLK_VIN_ID_SYS:
83 case CTRL_CLK_VIN_ID_XBAR:
84 case CTRL_CLK_VIN_ID_LTC:
85 data = gk20a_readl(g, fuse_vin_cal_shared_delta_r());
86 break;
87
88 case CTRL_CLK_VIN_ID_SRAM:
89 data = gk20a_readl(g, fuse_vin_cal_sram_delta_r());
90 break;
91
92 default:
93 return -EINVAL;
94 }
95 if (data == 0xFFFFFFFF)
96 return -EINVAL;
97
98 gpc0interceptdata = fuse_vin_cal_gpc0_icpt_data_v(gpc0data) * 1000;
99 gpc0interceptdata = gpc0interceptdata >>
100 fuse_vin_cal_gpc0_icpt_frac_size_v();
101
102 switch (vin_id) {
103 case CTRL_CLK_VIN_ID_GPC0:
104 break;
105
106 case CTRL_CLK_VIN_ID_GPC1:
107 case CTRL_CLK_VIN_ID_GPC2:
108 case CTRL_CLK_VIN_ID_GPC3:
109 case CTRL_CLK_VIN_ID_GPC4:
110 case CTRL_CLK_VIN_ID_GPC5:
111 case CTRL_CLK_VIN_ID_SYS:
112 case CTRL_CLK_VIN_ID_XBAR:
113 case CTRL_CLK_VIN_ID_LTC:
114 interceptdata =
115 (fuse_vin_cal_gpc1_icpt_data_v(data)) * 1000;
116 interceptdata = interceptdata >>
117 fuse_vin_cal_gpc1_icpt_frac_size_v();
118 break;
119
120 case CTRL_CLK_VIN_ID_SRAM:
121 interceptdata =
122 (fuse_vin_cal_sram_icpt_data_v(data)) * 1000;
123 interceptdata = interceptdata >>
124 fuse_vin_cal_sram_icpt_frac_size_v();
125 break;
126
127 default:
128 return -EINVAL;
129 }
130
131 if (data & fuse_vin_cal_gpc1_icpt_sign_f())
132 *intercept = gpc0interceptdata - interceptdata;
133 else
134 *intercept = gpc0interceptdata + interceptdata;
135
136 /* slope */
137 gpc0slopedata = (fuse_vin_cal_gpc0_slope_data_v(gpc0data)) * 1000;
138 gpc0slopedata = gpc0slopedata >>
139 fuse_vin_cal_gpc0_slope_frac_size_v();
140
141 switch (vin_id) {
142 case CTRL_CLK_VIN_ID_GPC0:
143 break;
144
145 case CTRL_CLK_VIN_ID_GPC1:
146 case CTRL_CLK_VIN_ID_GPC2:
147 case CTRL_CLK_VIN_ID_GPC3:
148 case CTRL_CLK_VIN_ID_GPC4:
149 case CTRL_CLK_VIN_ID_GPC5:
150 case CTRL_CLK_VIN_ID_SYS:
151 case CTRL_CLK_VIN_ID_XBAR:
152 case CTRL_CLK_VIN_ID_LTC:
153 case CTRL_CLK_VIN_ID_SRAM:
154 slopedata =
155 (fuse_vin_cal_gpc1_slope_data_v(data)) * 1000;
156 slopedata = slopedata >>
157 fuse_vin_cal_gpc1_slope_frac_size_v();
158 break;
159
160 default:
161 return -EINVAL;
162 }
163
164 if (data & fuse_vin_cal_gpc1_slope_sign_f())
165 *slope = gpc0slopedata - slopedata;
166 else
167 *slope = gpc0slopedata + slopedata;
168 return 0;
169}
170
171static u32 _clk_vin_devgrp_pmudatainit_super(struct gk20a *g,
172 struct boardobjgrp *pboardobjgrp,
173 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu)
174{
175 struct nv_pmu_clk_clk_vin_device_boardobjgrp_set_header *pset =
176 (struct nv_pmu_clk_clk_vin_device_boardobjgrp_set_header *)
177 pboardobjgrppmu;
178 struct avfsvinobjs *pvin_obbj = (struct avfsvinobjs *)pboardobjgrp;
179 u32 status = 0;
180
181 gk20a_dbg_info("");
182
183 status = boardobjgrp_pmudatainit_e32(g, pboardobjgrp, pboardobjgrppmu);
184
185 pset->b_vin_is_disable_allowed = pvin_obbj->vin_is_disable_allowed;
186
187 gk20a_dbg_info(" Done");
188 return status;
189}
190
191static u32 _clk_vin_devgrp_pmudata_instget(struct gk20a *g,
192 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
193 struct nv_pmu_boardobj **ppboardobjpmudata,
194 u8 idx)
195{
196 struct nv_pmu_clk_clk_vin_device_boardobj_grp_set *pgrp_set =
197 (struct nv_pmu_clk_clk_vin_device_boardobj_grp_set *)
198 pmuboardobjgrp;
199
200 gk20a_dbg_info("");
201
202 /*check whether pmuboardobjgrp has a valid boardobj in index*/
203 if (((u32)BIT(idx) &
204 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
205 return -EINVAL;
206
207 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
208 &pgrp_set->objects[idx].data.board_obj;
209 gk20a_dbg_info(" Done");
210 return 0;
211}
212
213static u32 _clk_vin_devgrp_pmustatus_instget(struct gk20a *g,
214 void *pboardobjgrppmu,
215 struct nv_pmu_boardobj_query **ppboardobjpmustatus,
216 u8 idx)
217{
218 struct nv_pmu_clk_clk_vin_device_boardobj_grp_get_status *pgrp_get_status =
219 (struct nv_pmu_clk_clk_vin_device_boardobj_grp_get_status *)
220 pboardobjgrppmu;
221
222 /*check whether pmuboardobjgrp has a valid boardobj in index*/
223 if (((u32)BIT(idx) &
224 pgrp_get_status->hdr.data.super.obj_mask.super.data[0]) == 0)
225 return -EINVAL;
226
227 *ppboardobjpmustatus = (struct nv_pmu_boardobj_query *)
228 &pgrp_get_status->objects[idx].data.board_obj;
229 return 0;
230}
231
232u32 clk_vin_sw_setup(struct gk20a *g)
233{
234 u32 status;
235 struct boardobjgrp *pboardobjgrp = NULL;
236 u32 slope;
237 u32 intercept;
238 struct vin_device *pvindev;
239 struct avfsvinobjs *pvinobjs;
240 u8 i;
241
242 gk20a_dbg_info("");
243
244 status = boardobjgrpconstruct_e32(&g->clk_pmu.avfs_vinobjs.super);
245 if (status) {
246 gk20a_err(dev_from_gk20a(g),
247 "error creating boardobjgrp for clk vin, statu - 0x%x",
248 status);
249 goto done;
250 }
251
252 pboardobjgrp = &g->clk_pmu.avfs_vinobjs.super.super;
253 pvinobjs = &g->clk_pmu.avfs_vinobjs;
254
255 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, CLK, VIN_DEVICE);
256
257 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
258 clk, CLK, clk_vin_device, CLK_VIN_DEVICE);
259 if (status) {
260 gk20a_err(dev_from_gk20a(g),
261 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
262 status);
263 goto done;
264 }
265
266 pboardobjgrp->pmudatainit = _clk_vin_devgrp_pmudatainit_super;
267 pboardobjgrp->pmudatainstget = _clk_vin_devgrp_pmudata_instget;
268 pboardobjgrp->pmustatusinstget = _clk_vin_devgrp_pmustatus_instget;
269
270 status = devinit_get_vin_device_table(g, &g->clk_pmu.avfs_vinobjs);
271 if (status)
272 goto done;
273
274 /*update vin calibration to fuse */
275 if (pvinobjs->calibration_rev_vbios == read_vin_cal_fuse_rev(g)) {
276 BOARDOBJGRP_FOR_EACH(&(pvinobjs->super.super),
277 struct vin_device *, pvindev, i) {
278 slope = 0;
279 intercept = 0;
280 pvindev = CLK_GET_VIN_DEVICE(pvinobjs, i);
281 status = read_vin_cal_slope_intercept_fuse(g,
282 pvindev->id, &slope, &intercept);
283 if (status) {
284 gk20a_err(dev_from_gk20a(g),
285 "err reading vin cal for id %x", pvindev->id);
286 goto done;
287 }
288 if (slope != 0 && intercept != 0) {
289 pvindev->slope = slope;
290 pvindev->intercept = intercept;
291 }
292 }
293 }
294 status = BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g,
295 &g->clk_pmu.avfs_vinobjs.super.super,
296 clk, CLK, clk_vin_device, CLK_VIN_DEVICE);
297 if (status) {
298 gk20a_err(dev_from_gk20a(g),
299 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
300 status);
301 goto done;
302 }
303
304done:
305 gk20a_dbg_info(" done status %x", status);
306 return status;
307}
308
309u32 clk_vin_pmu_setup(struct gk20a *g)
310{
311 u32 status;
312 struct boardobjgrp *pboardobjgrp = NULL;
313
314 gk20a_dbg_info("");
315
316 pboardobjgrp = &g->clk_pmu.avfs_vinobjs.super.super;
317
318 if (!pboardobjgrp->bconstructed)
319 return -EINVAL;
320
321 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
322
323 gk20a_dbg_info("Done");
324 return status;
325}
326
327static u32 devinit_get_vin_device_table(struct gk20a *g,
328 struct avfsvinobjs *pvinobjs)
329{
330 u32 status = 0;
331 u8 *vin_table_ptr = NULL;
332 struct vin_descriptor_header_10 vin_desc_table_header = { 0 };
333 struct vin_descriptor_entry_10 vin_desc_table_entry = { 0 };
334 u8 *vin_tbl_entry_ptr = NULL;
335 u32 index = 0;
336 u32 slope, intercept;
337 struct vin_device vin_dev_data;
338 struct vin_device *pvin_dev;
339
340 gk20a_dbg_info("");
341
342 if (g->ops.bios.get_perf_table_ptrs) {
343 vin_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
344 g->bios.clock_token, VIN_TABLE);
345 if (vin_table_ptr == NULL) {
346 status = -1;
347 goto done;
348 }
349 }
350
351 memcpy(&vin_desc_table_header, vin_table_ptr,
352 sizeof(struct vin_descriptor_header_10));
353
354 pvinobjs->calibration_rev_vbios =
355 BIOS_GET_FIELD(vin_desc_table_header.flags0,
356 NV_VIN_DESC_FLAGS0_VIN_CAL_REVISION);
357 pvinobjs->vin_is_disable_allowed =
358 BIOS_GET_FIELD(vin_desc_table_header.flags0,
359 NV_VIN_DESC_FLAGS0_DISABLE_CONTROL);
360
361 /* VIN calibration slope: XX.YYY mV/code => XXYYY uV/code*/
362 slope = ((BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
363 NV_VIN_DESC_VIN_CAL_SLOPE_INTEGER) * 1000)) +
364 ((BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
365 NV_VIN_DESC_VIN_CAL_SLOPE_FRACTION)));
366
367 /* VIN calibration intercept: ZZZ.W mV => ZZZW00 uV */
368 intercept = ((BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
369 NV_VIN_DESC_VIN_CAL_INTERCEPT_INTEGER) * 1000)) +
370 ((BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
371 NV_VIN_DESC_VIN_CAL_INTERCEPT_FRACTION) * 100));
372
373 /* Read table entries*/
374 vin_tbl_entry_ptr = vin_table_ptr + vin_desc_table_header.header_sizee;
375 for (index = 0; index < vin_desc_table_header.entry_count; index++) {
376 u32 vin_id;
377
378 memcpy(&vin_desc_table_entry, vin_tbl_entry_ptr,
379 sizeof(struct vin_descriptor_entry_10));
380
381 if (vin_desc_table_entry.vin_device_type == CTRL_CLK_VIN_TYPE_DISABLED)
382 continue;
383
384 vin_id = vin_desc_table_entry.vin_device_id;
385
386 vin_dev_data.super.type =
387 (u8)vin_desc_table_entry.vin_device_type;
388 vin_dev_data.id = (u8)vin_desc_table_entry.vin_device_id;
389 vin_dev_data.volt_domain_vbios =
390 (u8)vin_desc_table_entry.volt_domain_vbios;
391 vin_dev_data.slope = slope;
392 vin_dev_data.intercept = intercept;
393
394 vin_dev_data.flls_shared_mask = 0;
395
396 pvin_dev = construct_vin_device(g, (void *)&vin_dev_data);
397
398 status = boardobjgrp_objinsert(&pvinobjs->super.super,
399 (struct boardobj *)pvin_dev, index);
400
401 vin_tbl_entry_ptr += vin_desc_table_header.entry_size;
402 }
403
404done:
405 gk20a_dbg_info(" done status %x", status);
406 return status;
407}
408
409static struct vin_device *construct_vin_device(struct gk20a *g, void *pargs)
410{
411 struct boardobj *board_obj_ptr = NULL;
412 struct vin_device *pvin_dev;
413 struct vin_device *board_obj_vin_ptr = NULL;
414 u32 status;
415
416 gk20a_dbg_info("");
417 status = boardobj_construct_super(g, &board_obj_ptr,
418 sizeof(struct vin_device), pargs);
419 if (status)
420 return NULL;
421
422 /*got vin board obj allocated now fill it into boardobj grp*/
423 pvin_dev = (struct vin_device *)pargs;
424 board_obj_vin_ptr = (struct vin_device *)board_obj_ptr;
425 /* override super class interface */
426 board_obj_ptr->pmudatainit = vin_device_init_pmudata_super;
427 board_obj_vin_ptr->id = pvin_dev->id;
428 board_obj_vin_ptr->volt_domain_vbios = pvin_dev->volt_domain_vbios;
429 board_obj_vin_ptr->slope = pvin_dev->slope;
430 board_obj_vin_ptr->intercept = pvin_dev->intercept;
431 board_obj_vin_ptr->flls_shared_mask = pvin_dev->flls_shared_mask;
432 board_obj_vin_ptr->volt_domain = CTRL_VOLT_DOMAIN_LOGIC;
433
434 gk20a_dbg_info(" Done");
435
436 return (struct vin_device *)board_obj_ptr;
437}
438
439static u32 vin_device_init_pmudata_super(struct gk20a *g,
440 struct boardobj *board_obj_ptr,
441 struct nv_pmu_boardobj *ppmudata)
442{
443 u32 status = 0;
444 struct vin_device *pvin_dev;
445 struct nv_pmu_clk_clk_vin_device_boardobj_set *perf_pmu_data;
446
447 gk20a_dbg_info("");
448
449 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
450 if (status != 0)
451 return status;
452
453 pvin_dev = (struct vin_device *)board_obj_ptr;
454 perf_pmu_data = (struct nv_pmu_clk_clk_vin_device_boardobj_set *)
455 ppmudata;
456
457 perf_pmu_data->id = pvin_dev->id;
458 perf_pmu_data->intercept = pvin_dev->intercept;
459 perf_pmu_data->volt_domain = pvin_dev->volt_domain;
460 perf_pmu_data->slope = pvin_dev->slope;
461 perf_pmu_data->flls_shared_mask = pvin_dev->flls_shared_mask;
462
463 gk20a_dbg_info(" Done");
464
465 return status;
466}
diff --git a/drivers/gpu/nvgpu/clk/clk_vin.h b/drivers/gpu/nvgpu/clk/clk_vin.h
new file mode 100644
index 00000000..1ffd7971
--- /dev/null
+++ b/drivers/gpu/nvgpu/clk/clk_vin.h
@@ -0,0 +1,56 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _CLKVIN_H_
15#define _CLKVIN_H_
16
17#include "boardobj/boardobj.h"
18#include "boardobj/boardobjgrp.h"
19#include "clk.h"
20
21struct vin_device;
22struct clk_pmupstate;
23
24struct avfsvinobjs {
25 struct boardobjgrp_e32 super;
26 u8 calibration_rev_vbios;
27 u8 calibration_rev_fused;
28 bool vin_is_disable_allowed;
29};
30typedef u32 vin_device_state_load(struct gk20a *g,
31 struct clk_pmupstate *clk, struct vin_device *pdev);
32
33struct vin_device {
34 struct boardobj super;
35 u8 id;
36 u8 volt_domain;
37 u8 volt_domain_vbios;
38 u32 slope;
39 u32 intercept;
40 u32 flls_shared_mask;
41
42 vin_device_state_load *state_load;
43};
44
45/* get vin device object from descriptor table index*/
46#define CLK_GET_VIN_DEVICE(pvinobjs, dev_index) \
47 ((struct vin_device *)BOARDOBJGRP_OBJ_GET_BY_IDX( \
48 ((struct boardobjgrp *)&(pvinobjs->super.super)), (dev_index)))
49
50boardobj_construct construct_vindevice;
51boardobj_pmudatainit vindeviceinit_pmudata_super;
52
53u32 clk_vin_sw_setup(struct gk20a *g);
54u32 clk_vin_pmu_setup(struct gk20a *g);
55
56#endif
diff --git a/drivers/gpu/nvgpu/gp106/acr_gp106.c b/drivers/gpu/nvgpu/gp106/acr_gp106.c
new file mode 100644
index 00000000..5ed6300c
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/acr_gp106.c
@@ -0,0 +1,1169 @@
1/*
2 * Copyright (c) 2015-2016, 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
14#include <linux/delay.h> /* for mdelay */
15#include <linux/firmware.h>
16#include <linux/clk.h>
17#include <linux/module.h>
18#include <linux/debugfs.h>
19#include <linux/dma-mapping.h>
20#include <linux/io.h>
21
22#include "gk20a/gk20a.h"
23#include "gk20a/pmu_gk20a.h"
24#include "gk20a/semaphore_gk20a.h"
25#include "gp106/hw_psec_gp106.h"
26#include "gp106/hw_pwr_gp106.h"
27#include "gm206/acr_gm206.h"
28#include "gm20b/acr_gm20b.h"
29#include "gm206/pmu_gm206.h"
30#include "sec2_gp106.h"
31#include "nvgpu_gpuid_t18x.h"
32#include "nvgpu_common.h"
33
34/*Defines*/
35#define gp106_dbg_pmu(fmt, arg...) \
36 gk20a_dbg(gpu_dbg_pmu, fmt, ##arg)
37
38typedef int (*get_ucode_details)(struct gk20a *g,
39 struct flcn_ucode_img_v1 *udata);
40
41/* Both size and address of WPR need to be 128K-aligned */
42#define WPR_ALIGNMENT 0x20000
43#define GP106_DGPU_NONWPR NVGPU_VIDMEM_BOOTSTRAP_ALLOCATOR_BASE
44#define GP106_DGPU_WPR_OFFSET 0x400000
45#define DGPU_WPR_SIZE 0x100000
46
47/*Externs*/
48
49/*Forwards*/
50static int pmu_ucode_details(struct gk20a *g, struct flcn_ucode_img_v1 *p_img);
51static int fecs_ucode_details(struct gk20a *g,
52 struct flcn_ucode_img_v1 *p_img);
53static int gpccs_ucode_details(struct gk20a *g,
54 struct flcn_ucode_img_v1 *p_img);
55static int gp106_bootstrap_hs_flcn(struct gk20a *g);
56
57static int lsfm_discover_ucode_images(struct gk20a *g,
58 struct ls_flcn_mgr_v1 *plsfm);
59static int lsfm_add_ucode_img(struct gk20a *g, struct ls_flcn_mgr_v1 *plsfm,
60 struct flcn_ucode_img_v1 *ucode_image, u32 falcon_id);
61static void lsfm_free_ucode_img_res(struct flcn_ucode_img_v1 *p_img);
62static void lsfm_free_nonpmu_ucode_img_res(struct flcn_ucode_img_v1 *p_img);
63static int lsf_gen_wpr_requirements(struct gk20a *g,
64 struct ls_flcn_mgr_v1 *plsfm);
65static void lsfm_init_wpr_contents(struct gk20a *g,
66 struct ls_flcn_mgr_v1 *plsfm, struct mem_desc *nonwpr);
67static void free_acr_resources(struct gk20a *g, struct ls_flcn_mgr_v1 *plsfm);
68static int gp106_pmu_populate_loader_cfg(struct gk20a *g,
69 void *lsfm, u32 *p_bl_gen_desc_size);
70static int gp106_flcn_populate_bl_dmem_desc(struct gk20a *g,
71 void *lsfm, u32 *p_bl_gen_desc_size, u32 falconid);
72static int gp106_prepare_ucode_blob(struct gk20a *g);
73
74/*Globals*/
75static get_ucode_details pmu_acr_supp_ucode_list[] = {
76 pmu_ucode_details,
77 fecs_ucode_details,
78 gpccs_ucode_details,
79};
80
81static void gp106_wpr_info(struct gk20a *g, struct wpr_carveout_info *inf)
82{
83 inf->nonwpr_base = g->mm.vidmem.bootstrap_base;
84 inf->wpr_base = inf->nonwpr_base + GP106_DGPU_WPR_OFFSET;
85 inf->size = DGPU_WPR_SIZE;
86}
87
88static void flcn64_set_dma(struct falc_u64 *dma_addr, u64 value)
89{
90 dma_addr->lo |= u64_lo32(value);
91 dma_addr->hi |= u64_hi32(value);
92}
93
94static int gp106_alloc_blob_space(struct gk20a *g,
95 size_t size, struct mem_desc *mem)
96{
97 struct wpr_carveout_info wpr_inf;
98 int err;
99
100 if (mem->size)
101 return 0;
102
103 g->ops.pmu.get_wpr(g, &wpr_inf);
104
105 /*
106 * Even though this mem_desc wouldn't be used, the wpr region needs to
107 * be reserved in the allocator.
108 */
109 err = gk20a_gmmu_alloc_attr_vid_at(g, 0, wpr_inf.size,
110 &g->acr.wpr_dummy, wpr_inf.wpr_base);
111 if (err)
112 return err;
113
114 return gk20a_gmmu_alloc_attr_vid_at(g, 0, wpr_inf.size, mem,
115 wpr_inf.nonwpr_base);
116}
117
118void gp106_init_secure_pmu(struct gpu_ops *gops)
119{
120 gops->pmu.prepare_ucode = gp106_prepare_ucode_blob;
121 gops->pmu.pmu_setup_hw_and_bootstrap = gp106_bootstrap_hs_flcn;
122 gops->pmu.is_lazy_bootstrap = gm206_is_lazy_bootstrap;
123 gops->pmu.is_priv_load = gm206_is_priv_load;
124 gops->pmu.get_wpr = gp106_wpr_info;
125 gops->pmu.alloc_blob_space = gp106_alloc_blob_space;
126 gops->pmu.pmu_populate_loader_cfg = gp106_pmu_populate_loader_cfg;
127 gops->pmu.flcn_populate_bl_dmem_desc = gp106_flcn_populate_bl_dmem_desc;
128 gops->pmu.falcon_wait_for_halt = sec2_wait_for_halt;
129 gops->pmu.falcon_clear_halt_interrupt_status =
130 sec2_clear_halt_interrupt_status;
131 gops->pmu.init_falcon_setup_hw = init_sec2_setup_hw1;
132}
133/* TODO - check if any free blob res needed*/
134
135static int pmu_ucode_details(struct gk20a *g, struct flcn_ucode_img_v1 *p_img)
136{
137 const struct firmware *pmu_fw, *pmu_desc, *pmu_sig;
138 struct pmu_gk20a *pmu = &g->pmu;
139 struct lsf_ucode_desc_v1 *lsf_desc;
140 int err;
141
142 gp106_dbg_pmu("requesting PMU ucode in gp106\n");
143 pmu_fw = nvgpu_request_firmware(g, GM20B_PMU_UCODE_IMAGE,
144 NVGPU_REQUEST_FIRMWARE_NO_SOC);
145 if (!pmu_fw) {
146 gk20a_err(dev_from_gk20a(g), "failed to load pmu ucode!!");
147 return -ENOENT;
148 }
149 g->acr.pmu_fw = pmu_fw;
150 gp106_dbg_pmu("Loaded PMU ucode in for blob preparation");
151
152 gp106_dbg_pmu("requesting PMU ucode desc in GM20B\n");
153 pmu_desc = nvgpu_request_firmware(g, GM20B_PMU_UCODE_DESC,
154 NVGPU_REQUEST_FIRMWARE_NO_SOC);
155 if (!pmu_desc) {
156 gk20a_err(dev_from_gk20a(g), "failed to load pmu ucode desc!!");
157 err = -ENOENT;
158 goto release_img_fw;
159 }
160 pmu_sig = nvgpu_request_firmware(g, GM20B_PMU_UCODE_SIG,
161 NVGPU_REQUEST_FIRMWARE_NO_SOC);
162 if (!pmu_sig) {
163 gk20a_err(dev_from_gk20a(g), "failed to load pmu sig!!");
164 err = -ENOENT;
165 goto release_desc;
166 }
167 pmu->desc_v1 = (struct pmu_ucode_desc_v1 *)pmu_desc->data;
168 pmu->ucode_image = (u32 *)pmu_fw->data;
169 g->acr.pmu_desc = pmu_desc;
170
171 err = gk20a_init_pmu(pmu);
172 if (err) {
173 gp106_dbg_pmu("failed to set function pointers\n");
174 goto release_sig;
175 }
176
177 lsf_desc = kzalloc(sizeof(struct lsf_ucode_desc_v1), GFP_KERNEL);
178 if (!lsf_desc) {
179 err = -ENOMEM;
180 goto release_sig;
181 }
182 memcpy(lsf_desc, (void *)pmu_sig->data, sizeof(struct lsf_ucode_desc_v1));
183 lsf_desc->falcon_id = LSF_FALCON_ID_PMU;
184
185 p_img->desc = pmu->desc_v1;
186 p_img->data = pmu->ucode_image;
187 p_img->data_size = pmu->desc_v1->app_start_offset
188 + pmu->desc_v1->app_size;
189 p_img->fw_ver = NULL;
190 p_img->header = NULL;
191 p_img->lsf_desc = (struct lsf_ucode_desc_v1 *)lsf_desc;
192 gp106_dbg_pmu("requesting PMU ucode in GM20B exit\n");
193
194 release_firmware(pmu_sig);
195 return 0;
196release_sig:
197 release_firmware(pmu_sig);
198release_desc:
199 release_firmware(pmu_desc);
200release_img_fw:
201 release_firmware(pmu_fw);
202 return err;
203}
204
205static int fecs_ucode_details(struct gk20a *g, struct flcn_ucode_img_v1 *p_img)
206{
207 u32 ver = g->gpu_characteristics.arch + g->gpu_characteristics.impl;
208 struct lsf_ucode_desc_v1 *lsf_desc;
209 const struct firmware *fecs_sig = NULL;
210 int err;
211
212 switch (ver) {
213 case NVGPU_GPUID_GP104:
214 fecs_sig = nvgpu_request_firmware(g,
215 GP104_FECS_UCODE_SIG,
216 NVGPU_REQUEST_FIRMWARE_NO_SOC);
217 break;
218 case NVGPU_GPUID_GP106:
219 fecs_sig = nvgpu_request_firmware(g,
220 GP106_FECS_UCODE_SIG,
221 NVGPU_REQUEST_FIRMWARE_NO_SOC);
222 break;
223 default:
224 gk20a_err(g->dev, "no support for GPUID %x", ver);
225 }
226
227 if (!fecs_sig) {
228 gk20a_err(dev_from_gk20a(g), "failed to load fecs sig");
229 return -ENOENT;
230 }
231 lsf_desc = kzalloc(sizeof(struct lsf_ucode_desc_v1), GFP_KERNEL);
232 if (!lsf_desc) {
233 err = -ENOMEM;
234 goto rel_sig;
235 }
236 memcpy(lsf_desc, (void *)fecs_sig->data, sizeof(struct lsf_ucode_desc_v1));
237 lsf_desc->falcon_id = LSF_FALCON_ID_FECS;
238
239 p_img->desc = kzalloc(sizeof(struct pmu_ucode_desc_v1), GFP_KERNEL);
240 if (p_img->desc == NULL) {
241 err = -ENOMEM;
242 goto free_lsf_desc;
243 }
244
245 p_img->desc->bootloader_start_offset =
246 g->ctxsw_ucode_info.fecs.boot.offset;
247 p_img->desc->bootloader_size =
248 ALIGN(g->ctxsw_ucode_info.fecs.boot.size, 256);
249 p_img->desc->bootloader_imem_offset =
250 g->ctxsw_ucode_info.fecs.boot_imem_offset;
251 p_img->desc->bootloader_entry_point =
252 g->ctxsw_ucode_info.fecs.boot_entry;
253
254 p_img->desc->image_size =
255 ALIGN(g->ctxsw_ucode_info.fecs.boot.size, 256) +
256 ALIGN(g->ctxsw_ucode_info.fecs.code.size, 256) +
257 ALIGN(g->ctxsw_ucode_info.fecs.data.size, 256);
258 p_img->desc->app_size = ALIGN(g->ctxsw_ucode_info.fecs.code.size, 256) +
259 ALIGN(g->ctxsw_ucode_info.fecs.data.size, 256);
260 p_img->desc->app_start_offset = g->ctxsw_ucode_info.fecs.code.offset;
261 p_img->desc->app_imem_offset = 0;
262 p_img->desc->app_imem_entry = 0;
263 p_img->desc->app_dmem_offset = 0;
264 p_img->desc->app_resident_code_offset = 0;
265 p_img->desc->app_resident_code_size =
266 g->ctxsw_ucode_info.fecs.code.size;
267 p_img->desc->app_resident_data_offset =
268 g->ctxsw_ucode_info.fecs.data.offset -
269 g->ctxsw_ucode_info.fecs.code.offset;
270 p_img->desc->app_resident_data_size =
271 g->ctxsw_ucode_info.fecs.data.size;
272 p_img->data = g->ctxsw_ucode_info.surface_desc.cpu_va;
273 p_img->data_size = p_img->desc->image_size;
274
275 p_img->fw_ver = NULL;
276 p_img->header = NULL;
277 p_img->lsf_desc = (struct lsf_ucode_desc_v1 *)lsf_desc;
278 gp106_dbg_pmu("fecs fw loaded\n");
279 release_firmware(fecs_sig);
280 return 0;
281free_lsf_desc:
282 kfree(lsf_desc);
283rel_sig:
284 release_firmware(fecs_sig);
285 return err;
286}
287
288static int gpccs_ucode_details(struct gk20a *g, struct flcn_ucode_img_v1 *p_img)
289{
290 u32 ver = g->gpu_characteristics.arch + g->gpu_characteristics.impl;
291 struct lsf_ucode_desc_v1 *lsf_desc;
292 const struct firmware *gpccs_sig = NULL;
293 int err;
294
295 if (g->ops.securegpccs == false)
296 return -ENOENT;
297
298 switch (ver) {
299 case NVGPU_GPUID_GP104:
300 gpccs_sig = nvgpu_request_firmware(g,
301 GP104_GPCCS_UCODE_SIG,
302 NVGPU_REQUEST_FIRMWARE_NO_SOC);
303 break;
304 case NVGPU_GPUID_GP106:
305 gpccs_sig = nvgpu_request_firmware(g,
306 GP106_GPCCS_UCODE_SIG,
307 NVGPU_REQUEST_FIRMWARE_NO_SOC);
308 break;
309 default:
310 gk20a_err(g->dev, "no support for GPUID %x", ver);
311 }
312
313 if (!gpccs_sig) {
314 gk20a_err(dev_from_gk20a(g), "failed to load gpccs sig");
315 return -ENOENT;
316 }
317 lsf_desc = kzalloc(sizeof(struct lsf_ucode_desc_v1), GFP_KERNEL);
318 if (!lsf_desc) {
319 err = -ENOMEM;
320 goto rel_sig;
321 }
322 memcpy(lsf_desc, (void *)gpccs_sig->data,
323 sizeof(struct lsf_ucode_desc_v1));
324 lsf_desc->falcon_id = LSF_FALCON_ID_GPCCS;
325
326 p_img->desc = kzalloc(sizeof(struct pmu_ucode_desc_v1), GFP_KERNEL);
327 if (p_img->desc == NULL) {
328 err = -ENOMEM;
329 goto free_lsf_desc;
330 }
331
332 p_img->desc->bootloader_start_offset =
333 0;
334 p_img->desc->bootloader_size =
335 ALIGN(g->ctxsw_ucode_info.gpccs.boot.size, 256);
336 p_img->desc->bootloader_imem_offset =
337 g->ctxsw_ucode_info.gpccs.boot_imem_offset;
338 p_img->desc->bootloader_entry_point =
339 g->ctxsw_ucode_info.gpccs.boot_entry;
340
341 p_img->desc->image_size =
342 ALIGN(g->ctxsw_ucode_info.gpccs.boot.size, 256) +
343 ALIGN(g->ctxsw_ucode_info.gpccs.code.size, 256) +
344 ALIGN(g->ctxsw_ucode_info.gpccs.data.size, 256);
345 p_img->desc->app_size = ALIGN(g->ctxsw_ucode_info.gpccs.code.size, 256)
346 + ALIGN(g->ctxsw_ucode_info.gpccs.data.size, 256);
347 p_img->desc->app_start_offset = p_img->desc->bootloader_size;
348 p_img->desc->app_imem_offset = 0;
349 p_img->desc->app_imem_entry = 0;
350 p_img->desc->app_dmem_offset = 0;
351 p_img->desc->app_resident_code_offset = 0;
352 p_img->desc->app_resident_code_size =
353 ALIGN(g->ctxsw_ucode_info.gpccs.code.size, 256);
354 p_img->desc->app_resident_data_offset =
355 ALIGN(g->ctxsw_ucode_info.gpccs.data.offset, 256) -
356 ALIGN(g->ctxsw_ucode_info.gpccs.code.offset, 256);
357 p_img->desc->app_resident_data_size =
358 ALIGN(g->ctxsw_ucode_info.gpccs.data.size, 256);
359 p_img->data = (u32 *)((u8 *)g->ctxsw_ucode_info.surface_desc.cpu_va +
360 g->ctxsw_ucode_info.gpccs.boot.offset);
361 p_img->data_size = ALIGN(p_img->desc->image_size, 256);
362 p_img->fw_ver = NULL;
363 p_img->header = NULL;
364 p_img->lsf_desc = (struct lsf_ucode_desc_v1 *)lsf_desc;
365 gp106_dbg_pmu("gpccs fw loaded\n");
366 release_firmware(gpccs_sig);
367 return 0;
368free_lsf_desc:
369 kfree(lsf_desc);
370rel_sig:
371 release_firmware(gpccs_sig);
372 return err;
373}
374
375static int gp106_prepare_ucode_blob(struct gk20a *g)
376{
377
378 int err;
379 struct ls_flcn_mgr_v1 lsfm_l, *plsfm;
380 struct pmu_gk20a *pmu = &g->pmu;
381 struct wpr_carveout_info wpr_inf;
382
383 if (g->acr.ucode_blob.cpu_va) {
384 /*Recovery case, we do not need to form
385 non WPR blob of ucodes*/
386 err = gk20a_init_pmu(pmu);
387 if (err) {
388 gp106_dbg_pmu("failed to set function pointers\n");
389 return err;
390 }
391 return 0;
392 }
393 plsfm = &lsfm_l;
394 memset((void *)plsfm, 0, sizeof(struct ls_flcn_mgr_v1));
395 gp106_dbg_pmu("fetching GMMU regs\n");
396 gm20b_mm_mmu_vpr_info_fetch(g);
397 gr_gk20a_init_ctxsw_ucode(g);
398
399 g->ops.pmu.get_wpr(g, &wpr_inf);
400 gp106_dbg_pmu("wpr carveout base:%llx\n", (wpr_inf.wpr_base));
401 gp106_dbg_pmu("wpr carveout size :%x\n", (u32)wpr_inf.size);
402
403 /* Discover all managed falcons*/
404 err = lsfm_discover_ucode_images(g, plsfm);
405 gp106_dbg_pmu(" Managed Falcon cnt %d\n", plsfm->managed_flcn_cnt);
406 if (err)
407 goto exit_err;
408
409 if (plsfm->managed_flcn_cnt && !g->acr.ucode_blob.cpu_va) {
410 /* Generate WPR requirements*/
411 err = lsf_gen_wpr_requirements(g, plsfm);
412 if (err)
413 goto exit_err;
414
415 /*Alloc memory to hold ucode blob contents*/
416 err = g->ops.pmu.alloc_blob_space(g, plsfm->wpr_size
417 ,&g->acr.ucode_blob);
418 if (err)
419 goto exit_err;
420
421 gp106_dbg_pmu("managed LS falcon %d, WPR size %d bytes.\n",
422 plsfm->managed_flcn_cnt, plsfm->wpr_size);
423
424 lsfm_init_wpr_contents(g, plsfm, &g->acr.ucode_blob);
425 } else {
426 gp106_dbg_pmu("LSFM is managing no falcons.\n");
427 }
428 gp106_dbg_pmu("prepare ucode blob return 0\n");
429 free_acr_resources(g, plsfm);
430
431 exit_err:
432 return err;
433}
434
435static u8 lsfm_falcon_disabled(struct gk20a *g, struct ls_flcn_mgr_v1 *plsfm,
436 u32 falcon_id)
437{
438 return (plsfm->disable_mask >> falcon_id) & 0x1;
439}
440
441/* Discover all managed falcon ucode images */
442static int lsfm_discover_ucode_images(struct gk20a *g,
443 struct ls_flcn_mgr_v1 *plsfm)
444{
445 struct pmu_gk20a *pmu = &g->pmu;
446 struct flcn_ucode_img_v1 ucode_img;
447 u32 falcon_id;
448 u32 i;
449 int status;
450
451 /* LSFM requires a secure PMU, discover it first.*/
452 /* Obtain the PMU ucode image and add it to the list if required*/
453 memset(&ucode_img, 0, sizeof(ucode_img));
454 status = pmu_ucode_details(g, &ucode_img);
455 if (status == 0) {
456 if (ucode_img.lsf_desc != NULL) {
457 /* The falon_id is formed by grabbing the static base
458 * falon_id from the image and adding the
459 * engine-designated falcon instance.*/
460 pmu->pmu_mode |= PMU_SECURE_MODE;
461 falcon_id = ucode_img.lsf_desc->falcon_id +
462 ucode_img.flcn_inst;
463
464 if (!lsfm_falcon_disabled(g, plsfm, falcon_id)) {
465 pmu->falcon_id = falcon_id;
466 if (lsfm_add_ucode_img(g, plsfm, &ucode_img,
467 pmu->falcon_id) == 0)
468 pmu->pmu_mode |= PMU_LSFM_MANAGED;
469
470 plsfm->managed_flcn_cnt++;
471 } else {
472 gp106_dbg_pmu("id not managed %d\n",
473 ucode_img.lsf_desc->falcon_id);
474 }
475 }
476
477 /*Free any ucode image resources if not managing this falcon*/
478 if (!(pmu->pmu_mode & PMU_LSFM_MANAGED)) {
479 gp106_dbg_pmu("pmu is not LSFM managed\n");
480 lsfm_free_ucode_img_res(&ucode_img);
481 }
482 }
483
484 /* Enumerate all constructed falcon objects,
485 as we need the ucode image info and total falcon count.*/
486
487 /*0th index is always PMU which is already handled in earlier
488 if condition*/
489 for (i = 1; i < (MAX_SUPPORTED_LSFM); i++) {
490 memset(&ucode_img, 0, sizeof(ucode_img));
491 if (pmu_acr_supp_ucode_list[i](g, &ucode_img) == 0) {
492 if (ucode_img.lsf_desc != NULL) {
493 /* We have engine sigs, ensure that this falcon
494 is aware of the secure mode expectations
495 (ACR status)*/
496
497 /* falon_id is formed by grabbing the static
498 base falonId from the image and adding the
499 engine-designated falcon instance. */
500 falcon_id = ucode_img.lsf_desc->falcon_id +
501 ucode_img.flcn_inst;
502
503 if (!lsfm_falcon_disabled(g, plsfm,
504 falcon_id)) {
505 /* Do not manage non-FB ucode*/
506 if (lsfm_add_ucode_img(g,
507 plsfm, &ucode_img, falcon_id)
508 == 0)
509 plsfm->managed_flcn_cnt++;
510 } else {
511 gp106_dbg_pmu("not managed %d\n",
512 ucode_img.lsf_desc->falcon_id);
513 lsfm_free_nonpmu_ucode_img_res(
514 &ucode_img);
515 }
516 }
517 } else {
518 /* Consumed all available falcon objects */
519 gp106_dbg_pmu("Done checking for ucodes %d\n", i);
520 break;
521 }
522 }
523 return 0;
524}
525
526static int gp106_pmu_populate_loader_cfg(struct gk20a *g,
527 void *lsfm, u32 *p_bl_gen_desc_size)
528{
529 struct wpr_carveout_info wpr_inf;
530 struct pmu_gk20a *pmu = &g->pmu;
531 struct lsfm_managed_ucode_img_v2 *p_lsfm =
532 (struct lsfm_managed_ucode_img_v2 *)lsfm;
533 struct flcn_ucode_img_v1 *p_img = &(p_lsfm->ucode_img);
534 struct flcn_bl_dmem_desc_v1 *ldr_cfg =
535 &(p_lsfm->bl_gen_desc.bl_dmem_desc_v1);
536 u64 addr_base;
537 struct pmu_ucode_desc_v1 *desc;
538 u64 addr_code, addr_data;
539 u32 addr_args;
540
541 if (p_img->desc == NULL) /*This means its a header based ucode,
542 and so we do not fill BL gen desc structure*/
543 return -EINVAL;
544 desc = p_img->desc;
545 /*
546 Calculate physical and virtual addresses for various portions of
547 the PMU ucode image
548 Calculate the 32-bit addresses for the application code, application
549 data, and bootloader code. These values are all based on IM_BASE.
550 The 32-bit addresses will be the upper 32-bits of the virtual or
551 physical addresses of each respective segment.
552 */
553 addr_base = p_lsfm->lsb_header.ucode_off;
554 g->ops.pmu.get_wpr(g, &wpr_inf);
555 addr_base += (wpr_inf.wpr_base);
556
557 gp106_dbg_pmu("pmu loader cfg u32 addrbase %x\n", (u32)addr_base);
558 /*From linux*/
559 addr_code = u64_lo32((addr_base +
560 desc->app_start_offset +
561 desc->app_resident_code_offset) );
562 gp106_dbg_pmu("app start %d app res code off %d\n",
563 desc->app_start_offset, desc->app_resident_code_offset);
564 addr_data = u64_lo32((addr_base +
565 desc->app_start_offset +
566 desc->app_resident_data_offset) );
567 gp106_dbg_pmu("app res data offset%d\n",
568 desc->app_resident_data_offset);
569 gp106_dbg_pmu("bl start off %d\n", desc->bootloader_start_offset);
570
571 addr_args = ((pwr_falcon_hwcfg_dmem_size_v(
572 gk20a_readl(g, pwr_falcon_hwcfg_r())))
573 << GK20A_PMU_DMEM_BLKSIZE2);
574
575 addr_args -= g->ops.pmu_ver.get_pmu_cmdline_args_size(pmu);
576
577 gp106_dbg_pmu("addr_args %x\n", addr_args);
578
579 /* Populate the LOADER_CONFIG state */
580 memset((void *) ldr_cfg, 0, sizeof(struct flcn_bl_dmem_desc_v1));
581 ldr_cfg->ctx_dma = GK20A_PMU_DMAIDX_UCODE;
582 flcn64_set_dma(&ldr_cfg->code_dma_base, addr_code);
583 ldr_cfg->non_sec_code_off = desc->app_resident_code_offset;
584 ldr_cfg->non_sec_code_size = desc->app_resident_code_size;
585 flcn64_set_dma(&ldr_cfg->data_dma_base, addr_data);
586 ldr_cfg->data_size = desc->app_resident_data_size;
587 ldr_cfg->code_entry_point = desc->app_imem_entry;
588
589 /* Update the argc/argv members*/
590 ldr_cfg->argc = 1;
591 ldr_cfg->argv = addr_args;
592
593 *p_bl_gen_desc_size = sizeof(struct flcn_bl_dmem_desc_v1);
594
595 g->acr.pmu_args = addr_args;
596 return 0;
597}
598
599static int gp106_flcn_populate_bl_dmem_desc(struct gk20a *g,
600 void *lsfm, u32 *p_bl_gen_desc_size, u32 falconid)
601{
602 struct wpr_carveout_info wpr_inf;
603 struct lsfm_managed_ucode_img_v2 *p_lsfm =
604 (struct lsfm_managed_ucode_img_v2 *)lsfm;
605 struct flcn_ucode_img_v1 *p_img = &(p_lsfm->ucode_img);
606 struct flcn_bl_dmem_desc_v1 *ldr_cfg =
607 &(p_lsfm->bl_gen_desc.bl_dmem_desc_v1);
608 u64 addr_base;
609 struct pmu_ucode_desc_v1 *desc;
610 u64 addr_code, addr_data;
611
612 if (p_img->desc == NULL) /*This means its a header based ucode,
613 and so we do not fill BL gen desc structure*/
614 return -EINVAL;
615 desc = p_img->desc;
616
617 /*
618 Calculate physical and virtual addresses for various portions of
619 the PMU ucode image
620 Calculate the 32-bit addresses for the application code, application
621 data, and bootloader code. These values are all based on IM_BASE.
622 The 32-bit addresses will be the upper 32-bits of the virtual or
623 physical addresses of each respective segment.
624 */
625 addr_base = p_lsfm->lsb_header.ucode_off;
626 g->ops.pmu.get_wpr(g, &wpr_inf);
627 addr_base += (wpr_inf.wpr_base);
628
629 gp106_dbg_pmu("gen loader cfg %x u32 addrbase %x ID\n", (u32)addr_base,
630 p_lsfm->wpr_header.falcon_id);
631 addr_code = u64_lo32((addr_base +
632 desc->app_start_offset +
633 desc->app_resident_code_offset) );
634 addr_data = u64_lo32((addr_base +
635 desc->app_start_offset +
636 desc->app_resident_data_offset) );
637
638 gp106_dbg_pmu("gen cfg %x u32 addrcode %x & data %x load offset %xID\n",
639 (u32)addr_code, (u32)addr_data, desc->bootloader_start_offset,
640 p_lsfm->wpr_header.falcon_id);
641
642 /* Populate the LOADER_CONFIG state */
643 memset((void *) ldr_cfg, 0, sizeof(struct flcn_bl_dmem_desc_v1));
644 ldr_cfg->ctx_dma = GK20A_PMU_DMAIDX_UCODE;
645 flcn64_set_dma(&ldr_cfg->code_dma_base, addr_code);
646 ldr_cfg->non_sec_code_size = desc->app_resident_code_size;
647 flcn64_set_dma(&ldr_cfg->data_dma_base, addr_data);
648 ldr_cfg->data_size = desc->app_resident_data_size;
649 ldr_cfg->code_entry_point = desc->app_imem_entry;
650
651 *p_bl_gen_desc_size = sizeof(struct flcn_bl_dmem_desc_v1);
652 return 0;
653}
654
655/* Populate falcon boot loader generic desc.*/
656static int lsfm_fill_flcn_bl_gen_desc(struct gk20a *g,
657 struct lsfm_managed_ucode_img_v2 *pnode)
658{
659
660 struct pmu_gk20a *pmu = &g->pmu;
661 if (pnode->wpr_header.falcon_id != pmu->falcon_id) {
662 gp106_dbg_pmu("non pmu. write flcn bl gen desc\n");
663 g->ops.pmu.flcn_populate_bl_dmem_desc(g,
664 pnode, &pnode->bl_gen_desc_size,
665 pnode->wpr_header.falcon_id);
666 return 0;
667 }
668
669 if (pmu->pmu_mode & PMU_LSFM_MANAGED) {
670 gp106_dbg_pmu("pmu write flcn bl gen desc\n");
671 if (pnode->wpr_header.falcon_id == pmu->falcon_id)
672 return g->ops.pmu.pmu_populate_loader_cfg(g, pnode,
673 &pnode->bl_gen_desc_size);
674 }
675
676 /* Failed to find the falcon requested. */
677 return -ENOENT;
678}
679
680/* Initialize WPR contents */
681static void lsfm_init_wpr_contents(struct gk20a *g,
682 struct ls_flcn_mgr_v1 *plsfm, struct mem_desc *ucode)
683{
684 struct lsfm_managed_ucode_img_v2 *pnode = plsfm->ucode_img_list;
685 u32 i;
686
687 /* The WPR array is at the base of the WPR */
688 pnode = plsfm->ucode_img_list;
689 i = 0;
690
691 /*
692 * Walk the managed falcons, flush WPR and LSB headers to FB.
693 * flush any bl args to the storage area relative to the
694 * ucode image (appended on the end as a DMEM area).
695 */
696 while (pnode) {
697 /* Flush WPR header to memory*/
698 gk20a_mem_wr_n(g, ucode, i * sizeof(pnode->wpr_header),
699 &pnode->wpr_header, sizeof(pnode->wpr_header));
700
701 gp106_dbg_pmu("wpr header");
702 gp106_dbg_pmu("falconid :%d",
703 pnode->wpr_header.falcon_id);
704 gp106_dbg_pmu("lsb_offset :%x",
705 pnode->wpr_header.lsb_offset);
706 gp106_dbg_pmu("bootstrap_owner :%d",
707 pnode->wpr_header.bootstrap_owner);
708 gp106_dbg_pmu("lazy_bootstrap :%d",
709 pnode->wpr_header.lazy_bootstrap);
710 gp106_dbg_pmu("status :%d",
711 pnode->wpr_header.status);
712
713 /*Flush LSB header to memory*/
714 gk20a_mem_wr_n(g, ucode, pnode->wpr_header.lsb_offset,
715 &pnode->lsb_header, sizeof(pnode->lsb_header));
716
717 gp106_dbg_pmu("lsb header");
718 gp106_dbg_pmu("ucode_off :%x",
719 pnode->lsb_header.ucode_off);
720 gp106_dbg_pmu("ucode_size :%x",
721 pnode->lsb_header.ucode_size);
722 gp106_dbg_pmu("data_size :%x",
723 pnode->lsb_header.data_size);
724 gp106_dbg_pmu("bl_code_size :%x",
725 pnode->lsb_header.bl_code_size);
726 gp106_dbg_pmu("bl_imem_off :%x",
727 pnode->lsb_header.bl_imem_off);
728 gp106_dbg_pmu("bl_data_off :%x",
729 pnode->lsb_header.bl_data_off);
730 gp106_dbg_pmu("bl_data_size :%x",
731 pnode->lsb_header.bl_data_size);
732 gp106_dbg_pmu("app_code_off :%x",
733 pnode->lsb_header.app_code_off);
734 gp106_dbg_pmu("app_code_size :%x",
735 pnode->lsb_header.app_code_size);
736 gp106_dbg_pmu("app_data_off :%x",
737 pnode->lsb_header.app_data_off);
738 gp106_dbg_pmu("app_data_size :%x",
739 pnode->lsb_header.app_data_size);
740 gp106_dbg_pmu("flags :%x",
741 pnode->lsb_header.flags);
742
743 /*If this falcon has a boot loader and related args,
744 * flush them.*/
745 if (!pnode->ucode_img.header) {
746 /*Populate gen bl and flush to memory*/
747 lsfm_fill_flcn_bl_gen_desc(g, pnode);
748 gk20a_mem_wr_n(g, ucode,
749 pnode->lsb_header.bl_data_off,
750 &pnode->bl_gen_desc,
751 pnode->bl_gen_desc_size);
752 }
753 /*Copying of ucode*/
754 gk20a_mem_wr_n(g, ucode, pnode->lsb_header.ucode_off,
755 pnode->ucode_img.data,
756 pnode->ucode_img.data_size);
757 pnode = pnode->next;
758 i++;
759 }
760
761 /* Tag the terminator WPR header with an invalid falcon ID. */
762 gk20a_mem_wr32(g, ucode,
763 plsfm->managed_flcn_cnt * sizeof(struct lsf_wpr_header) +
764 offsetof(struct lsf_wpr_header, falcon_id),
765 LSF_FALCON_ID_INVALID);
766}
767
768/*!
769 * lsfm_parse_no_loader_ucode: parses UCODE header of falcon
770 *
771 * @param[in] p_ucodehdr : UCODE header
772 * @param[out] lsb_hdr : updates values in LSB header
773 *
774 * @return 0
775 */
776static int lsfm_parse_no_loader_ucode(u32 *p_ucodehdr,
777 struct lsf_lsb_header_v1 *lsb_hdr)
778{
779
780 u32 code_size = 0;
781 u32 data_size = 0;
782 u32 i = 0;
783 u32 total_apps = p_ucodehdr[FLCN_NL_UCODE_HDR_NUM_APPS_IND];
784
785 /* Lets calculate code size*/
786 code_size += p_ucodehdr[FLCN_NL_UCODE_HDR_OS_CODE_SIZE_IND];
787 for (i = 0; i < total_apps; i++) {
788 code_size += p_ucodehdr[FLCN_NL_UCODE_HDR_APP_CODE_SIZE_IND
789 (total_apps, i)];
790 }
791 code_size += p_ucodehdr[FLCN_NL_UCODE_HDR_OS_OVL_SIZE_IND(total_apps)];
792
793 /* Calculate data size*/
794 data_size += p_ucodehdr[FLCN_NL_UCODE_HDR_OS_DATA_SIZE_IND];
795 for (i = 0; i < total_apps; i++) {
796 data_size += p_ucodehdr[FLCN_NL_UCODE_HDR_APP_DATA_SIZE_IND
797 (total_apps, i)];
798 }
799
800 lsb_hdr->ucode_size = code_size;
801 lsb_hdr->data_size = data_size;
802 lsb_hdr->bl_code_size = p_ucodehdr[FLCN_NL_UCODE_HDR_OS_CODE_SIZE_IND];
803 lsb_hdr->bl_imem_off = 0;
804 lsb_hdr->bl_data_off = p_ucodehdr[FLCN_NL_UCODE_HDR_OS_DATA_OFF_IND];
805 lsb_hdr->bl_data_size = p_ucodehdr[FLCN_NL_UCODE_HDR_OS_DATA_SIZE_IND];
806 return 0;
807}
808
809/*!
810 * @brief lsfm_fill_static_lsb_hdr_info
811 * Populate static LSB header infomation using the provided ucode image
812 */
813static void lsfm_fill_static_lsb_hdr_info(struct gk20a *g,
814 u32 falcon_id, struct lsfm_managed_ucode_img_v2 *pnode)
815{
816
817 struct pmu_gk20a *pmu = &g->pmu;
818 u32 full_app_size = 0;
819 u32 data = 0;
820
821 if (pnode->ucode_img.lsf_desc)
822 memcpy(&pnode->lsb_header.signature, pnode->ucode_img.lsf_desc,
823 sizeof(struct lsf_ucode_desc_v1));
824 pnode->lsb_header.ucode_size = pnode->ucode_img.data_size;
825
826 /* The remainder of the LSB depends on the loader usage */
827 if (pnode->ucode_img.header) {
828 /* Does not use a loader */
829 pnode->lsb_header.data_size = 0;
830 pnode->lsb_header.bl_code_size = 0;
831 pnode->lsb_header.bl_data_off = 0;
832 pnode->lsb_header.bl_data_size = 0;
833
834 lsfm_parse_no_loader_ucode(pnode->ucode_img.header,
835 &(pnode->lsb_header));
836
837 /* Load the first 256 bytes of IMEM. */
838 /* Set LOAD_CODE_AT_0 and DMACTL_REQ_CTX.
839 True for all method based falcons */
840 data = NV_FLCN_ACR_LSF_FLAG_LOAD_CODE_AT_0_TRUE |
841 NV_FLCN_ACR_LSF_FLAG_DMACTL_REQ_CTX_TRUE;
842 pnode->lsb_header.flags = data;
843 } else {
844 /* Uses a loader. that is has a desc */
845 pnode->lsb_header.data_size = 0;
846
847 /* The loader code size is already aligned (padded) such that
848 the code following it is aligned, but the size in the image
849 desc is not, bloat it up to be on a 256 byte alignment. */
850 pnode->lsb_header.bl_code_size = ALIGN(
851 pnode->ucode_img.desc->bootloader_size,
852 LSF_BL_CODE_SIZE_ALIGNMENT);
853 full_app_size = ALIGN(pnode->ucode_img.desc->app_size,
854 LSF_BL_CODE_SIZE_ALIGNMENT) +
855 pnode->lsb_header.bl_code_size;
856 pnode->lsb_header.ucode_size = ALIGN(
857 pnode->ucode_img.desc->app_resident_data_offset,
858 LSF_BL_CODE_SIZE_ALIGNMENT) +
859 pnode->lsb_header.bl_code_size;
860 pnode->lsb_header.data_size = full_app_size -
861 pnode->lsb_header.ucode_size;
862 /* Though the BL is located at 0th offset of the image, the VA
863 is different to make sure that it doesnt collide the actual OS
864 VA range */
865 pnode->lsb_header.bl_imem_off =
866 pnode->ucode_img.desc->bootloader_imem_offset;
867
868 /* TODO: OBJFLCN should export properties using which the below
869 flags should be populated.*/
870 pnode->lsb_header.flags = 0;
871
872 if (falcon_id == pmu->falcon_id) {
873 data = NV_FLCN_ACR_LSF_FLAG_DMACTL_REQ_CTX_TRUE;
874 pnode->lsb_header.flags = data;
875 }
876
877 if(g->ops.pmu.is_priv_load(falcon_id))
878 pnode->lsb_header.flags |=
879 NV_FLCN_ACR_LSF_FLAG_FORCE_PRIV_LOAD_TRUE;
880 }
881}
882
883/* Adds a ucode image to the list of managed ucode images managed. */
884static int lsfm_add_ucode_img(struct gk20a *g, struct ls_flcn_mgr_v1 *plsfm,
885 struct flcn_ucode_img_v1 *ucode_image, u32 falcon_id)
886{
887 struct lsfm_managed_ucode_img_v2 *pnode;
888
889 pnode = kzalloc(sizeof(struct lsfm_managed_ucode_img_v2), GFP_KERNEL);
890 if (pnode == NULL)
891 return -ENOMEM;
892
893 /* Keep a copy of the ucode image info locally */
894 memcpy(&pnode->ucode_img, ucode_image, sizeof(struct flcn_ucode_img_v1));
895
896 /* Fill in static WPR header info*/
897 pnode->wpr_header.falcon_id = falcon_id;
898 pnode->wpr_header.bootstrap_owner = 0x07; //LSF_BOOTSTRAP_OWNER_DEFAULT;
899 pnode->wpr_header.status = LSF_IMAGE_STATUS_COPY;
900
901 pnode->wpr_header.lazy_bootstrap =
902 g->ops.pmu.is_lazy_bootstrap(falcon_id);
903
904 /*TODO to check if PDB_PROP_FLCN_LAZY_BOOTSTRAP is to be supported by
905 Android */
906 /* Fill in static LSB header info elsewhere */
907 lsfm_fill_static_lsb_hdr_info(g, falcon_id, pnode);
908 pnode->wpr_header.bin_version = pnode->lsb_header.signature.version;
909 pnode->next = plsfm->ucode_img_list;
910 plsfm->ucode_img_list = pnode;
911 return 0;
912}
913
914/* Free any ucode image structure resources*/
915static void lsfm_free_ucode_img_res(struct flcn_ucode_img_v1 *p_img)
916{
917 if (p_img->lsf_desc != NULL) {
918 kfree(p_img->lsf_desc);
919 p_img->lsf_desc = NULL;
920 }
921}
922
923/* Free any ucode image structure resources*/
924static void lsfm_free_nonpmu_ucode_img_res(struct flcn_ucode_img_v1 *p_img)
925{
926 if (p_img->lsf_desc != NULL) {
927 kfree(p_img->lsf_desc);
928 p_img->lsf_desc = NULL;
929 }
930 if (p_img->desc != NULL) {
931 kfree(p_img->desc);
932 p_img->desc = NULL;
933 }
934}
935
936static void free_acr_resources(struct gk20a *g, struct ls_flcn_mgr_v1 *plsfm)
937{
938 u32 cnt = plsfm->managed_flcn_cnt;
939 struct lsfm_managed_ucode_img_v2 *mg_ucode_img;
940
941 while (cnt) {
942 mg_ucode_img = plsfm->ucode_img_list;
943 if (mg_ucode_img->ucode_img.lsf_desc->falcon_id ==
944 LSF_FALCON_ID_PMU)
945 lsfm_free_ucode_img_res(&mg_ucode_img->ucode_img);
946 else
947 lsfm_free_nonpmu_ucode_img_res(
948 &mg_ucode_img->ucode_img);
949 plsfm->ucode_img_list = mg_ucode_img->next;
950 kfree(mg_ucode_img);
951 cnt--;
952 }
953}
954
955/* Generate WPR requirements for ACR allocation request */
956static int lsf_gen_wpr_requirements(struct gk20a *g,
957 struct ls_flcn_mgr_v1 *plsfm)
958{
959 struct lsfm_managed_ucode_img_v2 *pnode = plsfm->ucode_img_list;
960 u32 wpr_offset;
961
962 /* Calculate WPR size required */
963
964 /* Start with an array of WPR headers at the base of the WPR.
965 The expectation here is that the secure falcon will do a single DMA
966 read of this array and cache it internally so it's OK to pack these.
967 Also, we add 1 to the falcon count to indicate the end of the array.*/
968 wpr_offset = sizeof(struct lsf_wpr_header_v1) *
969 (plsfm->managed_flcn_cnt+1);
970
971 /* Walk the managed falcons, accounting for the LSB structs
972 as well as the ucode images. */
973 while (pnode) {
974 /* Align, save off, and include an LSB header size */
975 wpr_offset = ALIGN(wpr_offset,
976 LSF_LSB_HEADER_ALIGNMENT);
977 pnode->wpr_header.lsb_offset = wpr_offset;
978 wpr_offset += sizeof(struct lsf_lsb_header_v1);
979
980 /* Align, save off, and include the original (static)
981 ucode image size */
982 wpr_offset = ALIGN(wpr_offset,
983 LSF_UCODE_DATA_ALIGNMENT);
984 pnode->lsb_header.ucode_off = wpr_offset;
985 wpr_offset += pnode->ucode_img.data_size;
986
987 /* For falcons that use a boot loader (BL), we append a loader
988 desc structure on the end of the ucode image and consider this
989 the boot loader data. The host will then copy the loader desc
990 args to this space within the WPR region (before locking down)
991 and the HS bin will then copy them to DMEM 0 for the loader. */
992 if (!pnode->ucode_img.header) {
993 /* Track the size for LSB details filled in later
994 Note that at this point we don't know what kind of i
995 boot loader desc, so we just take the size of the
996 generic one, which is the largest it will will ever be.
997 */
998 /* Align (size bloat) and save off generic
999 descriptor size*/
1000 pnode->lsb_header.bl_data_size = ALIGN(
1001 sizeof(pnode->bl_gen_desc),
1002 LSF_BL_DATA_SIZE_ALIGNMENT);
1003
1004 /*Align, save off, and include the additional BL data*/
1005 wpr_offset = ALIGN(wpr_offset,
1006 LSF_BL_DATA_ALIGNMENT);
1007 pnode->lsb_header.bl_data_off = wpr_offset;
1008 wpr_offset += pnode->lsb_header.bl_data_size;
1009 } else {
1010 /* bl_data_off is already assigned in static
1011 information. But that is from start of the image */
1012 pnode->lsb_header.bl_data_off +=
1013 (wpr_offset - pnode->ucode_img.data_size);
1014 }
1015
1016 /* Finally, update ucode surface size to include updates */
1017 pnode->full_ucode_size = wpr_offset -
1018 pnode->lsb_header.ucode_off;
1019 if (pnode->wpr_header.falcon_id != LSF_FALCON_ID_PMU) {
1020 pnode->lsb_header.app_code_off =
1021 pnode->lsb_header.bl_code_size;
1022 pnode->lsb_header.app_code_size =
1023 pnode->lsb_header.ucode_size -
1024 pnode->lsb_header.bl_code_size;
1025 pnode->lsb_header.app_data_off =
1026 pnode->lsb_header.ucode_size;
1027 pnode->lsb_header.app_data_size =
1028 pnode->lsb_header.data_size;
1029 }
1030 pnode = pnode->next;
1031 }
1032 plsfm->wpr_size = wpr_offset;
1033 return 0;
1034}
1035
1036/*Loads ACR bin to FB mem and bootstraps PMU with bootloader code
1037 * start and end are addresses of ucode blob in non-WPR region*/
1038static int gp106_bootstrap_hs_flcn(struct gk20a *g)
1039{
1040 struct mm_gk20a *mm = &g->mm;
1041 struct vm_gk20a *vm = &mm->pmu.vm;
1042 int err = 0;
1043 u64 *acr_dmem;
1044 u32 img_size_in_bytes = 0;
1045 u32 status;
1046 struct acr_desc *acr = &g->acr;
1047 const struct firmware *acr_fw = acr->acr_fw;
1048 struct flcn_bl_dmem_desc_v1 *bl_dmem_desc = &acr->bl_dmem_desc_v1;
1049 u32 *acr_ucode_header_t210_load;
1050 u32 *acr_ucode_data_t210_load;
1051 struct wpr_carveout_info wpr_inf;
1052
1053 gp106_dbg_pmu("");
1054
1055 if (!acr_fw) {
1056 /*First time init case*/
1057 acr_fw = nvgpu_request_firmware(g,
1058 GM20B_HSBIN_PMU_UCODE_IMAGE,
1059 NVGPU_REQUEST_FIRMWARE_NO_SOC);
1060 if (!acr_fw) {
1061 gk20a_err(dev_from_gk20a(g), "pmu ucode get fail");
1062 return -ENOENT;
1063 }
1064 acr->acr_fw = acr_fw;
1065 acr->hsbin_hdr = (struct bin_hdr *)acr_fw->data;
1066 acr->fw_hdr = (struct acr_fw_header *)(acr_fw->data +
1067 acr->hsbin_hdr->header_offset);
1068 acr_ucode_data_t210_load = (u32 *)(acr_fw->data +
1069 acr->hsbin_hdr->data_offset);
1070 acr_ucode_header_t210_load = (u32 *)(acr_fw->data +
1071 acr->fw_hdr->hdr_offset);
1072 img_size_in_bytes = ALIGN((acr->hsbin_hdr->data_size), 256);
1073
1074 /* Lets patch the signatures first.. */
1075 if (acr_ucode_patch_sig(g, acr_ucode_data_t210_load,
1076 (u32 *)(acr_fw->data +
1077 acr->fw_hdr->sig_prod_offset),
1078 (u32 *)(acr_fw->data +
1079 acr->fw_hdr->sig_dbg_offset),
1080 (u32 *)(acr_fw->data +
1081 acr->fw_hdr->patch_loc),
1082 (u32 *)(acr_fw->data +
1083 acr->fw_hdr->patch_sig)) < 0) {
1084 gk20a_err(dev_from_gk20a(g), "patch signatures fail");
1085 err = -1;
1086 goto err_release_acr_fw;
1087 }
1088 err = gk20a_gmmu_alloc_map_sys(vm, img_size_in_bytes,
1089 &acr->acr_ucode);
1090 if (err) {
1091 err = -ENOMEM;
1092 goto err_release_acr_fw;
1093 }
1094
1095 g->ops.pmu.get_wpr(g, &wpr_inf);
1096
1097 acr_dmem = (u64 *)
1098 &(((u8 *)acr_ucode_data_t210_load)[
1099 acr_ucode_header_t210_load[2]]);
1100 acr->acr_dmem_desc_v1 = (struct flcn_acr_desc_v1 *)((u8 *)(
1101 acr->acr_ucode.cpu_va) + acr_ucode_header_t210_load[2]);
1102 ((struct flcn_acr_desc_v1 *)acr_dmem)->nonwpr_ucode_blob_start =
1103 wpr_inf.nonwpr_base;
1104 ((struct flcn_acr_desc_v1 *)acr_dmem)->nonwpr_ucode_blob_size =
1105 wpr_inf.size;
1106 ((struct flcn_acr_desc_v1 *)acr_dmem)->regions.no_regions = 1;
1107 ((struct flcn_acr_desc_v1 *)acr_dmem)->wpr_offset = 0;
1108
1109 ((struct flcn_acr_desc_v1 *)acr_dmem)->wpr_region_id = 1;
1110 ((struct flcn_acr_desc_v1 *)acr_dmem)->regions.region_props[
1111 0].region_id = 1;
1112 ((struct flcn_acr_desc_v1 *)acr_dmem)->regions.region_props[
1113 0].start_addr = (wpr_inf.wpr_base ) >> 8;
1114 ((struct flcn_acr_desc_v1 *)acr_dmem)->regions.region_props[
1115 0].end_addr = ((wpr_inf.wpr_base) + wpr_inf.size) >> 8;
1116 ((struct flcn_acr_desc_v1 *)acr_dmem)->regions.region_props[
1117 0].shadowmMem_startaddress = wpr_inf.nonwpr_base >> 8;
1118
1119 gk20a_mem_wr_n(g, &acr->acr_ucode, 0,
1120 acr_ucode_data_t210_load, img_size_in_bytes);
1121
1122 /*
1123 * In order to execute this binary, we will be using
1124 * a bootloader which will load this image into PMU IMEM/DMEM.
1125 * Fill up the bootloader descriptor for PMU HAL to use..
1126 * TODO: Use standard descriptor which the generic bootloader is
1127 * checked in.
1128 */
1129
1130 bl_dmem_desc->signature[0] = 0;
1131 bl_dmem_desc->signature[1] = 0;
1132 bl_dmem_desc->signature[2] = 0;
1133 bl_dmem_desc->signature[3] = 0;
1134 bl_dmem_desc->ctx_dma = GK20A_PMU_DMAIDX_VIRT;
1135 flcn64_set_dma( &bl_dmem_desc->code_dma_base,
1136 acr->acr_ucode.gpu_va);
1137 bl_dmem_desc->non_sec_code_off = acr_ucode_header_t210_load[0];
1138 bl_dmem_desc->non_sec_code_size = acr_ucode_header_t210_load[1];
1139 bl_dmem_desc->sec_code_off = acr_ucode_header_t210_load[5];
1140 bl_dmem_desc->sec_code_size = acr_ucode_header_t210_load[6];
1141 bl_dmem_desc->code_entry_point = 0; /* Start at 0th offset */
1142 flcn64_set_dma( &bl_dmem_desc->data_dma_base,
1143 acr->acr_ucode.gpu_va +
1144 (acr_ucode_header_t210_load[2]));
1145 bl_dmem_desc->data_size = acr_ucode_header_t210_load[3];
1146 } else
1147 acr->acr_dmem_desc->nonwpr_ucode_blob_size = 0;
1148
1149 status = pmu_exec_gen_bl(g, bl_dmem_desc, 1);
1150 if (status != 0) {
1151 err = status;
1152 goto err_free_ucode_map;
1153 }
1154
1155 /* sec2 reset - to keep it idle */
1156 gk20a_writel(g, psec_falcon_engine_r(),
1157 pwr_falcon_engine_reset_true_f());
1158 udelay(10);
1159 gk20a_writel(g, psec_falcon_engine_r(),
1160 pwr_falcon_engine_reset_false_f());
1161
1162 return 0;
1163err_free_ucode_map:
1164 gk20a_gmmu_unmap_free(vm, &acr->acr_ucode);
1165err_release_acr_fw:
1166 release_firmware(acr_fw);
1167 acr->acr_fw = NULL;
1168 return err;
1169}
diff --git a/drivers/gpu/nvgpu/gp106/acr_gp106.h b/drivers/gpu/nvgpu/gp106/acr_gp106.h
new file mode 100644
index 00000000..cd555eb8
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/acr_gp106.h
@@ -0,0 +1,128 @@
1/*
2 * Copyright (c) 2016, 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
14#ifndef __ACR_GP106_H_
15#define __ACR_GP106_H_
16
17#include "gm20b/acr_gm20b.h"
18#include "gm206/acr_gm206.h"
19
20#define GP106_FECS_UCODE_SIG "gp106/fecs_sig.bin"
21#define GP106_GPCCS_UCODE_SIG "gp106/gpccs_sig.bin"
22#define GP104_FECS_UCODE_SIG "gp104/fecs_sig.bin"
23#define GP104_GPCCS_UCODE_SIG "gp104/gpccs_sig.bin"
24
25struct lsf_ucode_desc_v1 {
26 u8 prd_keys[2][16];
27 u8 dbg_keys[2][16];
28 u32 b_prd_present;
29 u32 b_dbg_present;
30 u32 falcon_id;
31 u32 bsupports_versioning;
32 u32 version;
33 u32 dep_map_count;
34 u8 dep_map[LSF_FALCON_ID_END * 2 * 4];
35 u8 kdf[16];
36};
37
38struct lsf_wpr_header_v1 {
39 u32 falcon_id;
40 u32 lsb_offset;
41 u32 bootstrap_owner;
42 u32 lazy_bootstrap;
43 u32 bin_version;
44 u32 status;
45};
46
47struct lsf_lsb_header_v1 {
48 struct lsf_ucode_desc_v1 signature;
49 u32 ucode_off;
50 u32 ucode_size;
51 u32 data_size;
52 u32 bl_code_size;
53 u32 bl_imem_off;
54 u32 bl_data_off;
55 u32 bl_data_size;
56 u32 app_code_off;
57 u32 app_code_size;
58 u32 app_data_off;
59 u32 app_data_size;
60 u32 flags;
61};
62
63struct flcn_ucode_img_v1 {
64 u32 *header; /*only some falcons have header*/
65 u32 *data;
66 struct pmu_ucode_desc_v1 *desc; /*only some falcons have descriptor*/
67 u32 data_size;
68 void *fw_ver; /*NV2080_CTRL_GPU_GET_FIRMWARE_VERSION_PARAMS struct*/
69 u8 load_entire_os_data; /* load the whole osData section at boot time.*/
70 struct lsf_ucode_desc_v1 *lsf_desc; /* NULL if not a light secure falcon.*/
71 u8 free_res_allocs;/*True if there a resources to freed by the client.*/
72 u32 flcn_inst;
73};
74
75struct lsfm_managed_ucode_img_v2 {
76 struct lsfm_managed_ucode_img_v2 *next;
77 struct lsf_wpr_header_v1 wpr_header;
78 struct lsf_lsb_header_v1 lsb_header;
79 union flcn_bl_generic_desc_v1 bl_gen_desc;
80 u32 bl_gen_desc_size;
81 u32 full_ucode_size;
82 struct flcn_ucode_img_v1 ucode_img;
83};
84struct ls_flcn_mgr_v1 {
85 u16 managed_flcn_cnt;
86 u32 wpr_size;
87 u32 disable_mask;
88 struct lsfm_managed_ucode_img_v2 *ucode_img_list;
89 void *wpr_client_req_state;/*PACR_CLIENT_REQUEST_STATE originally*/
90};
91
92struct flcn_acr_region_prop_v1 {
93 u32 start_addr;
94 u32 end_addr;
95 u32 region_id;
96 u32 read_mask;
97 u32 write_mask;
98 u32 client_mask;
99 u32 shadowmMem_startaddress;
100};
101
102/*!
103 * no_regions - Number of regions used.
104 * region_props - Region properties
105 */
106struct flcn_acr_regions_v1 {
107 u32 no_regions;
108 struct flcn_acr_region_prop_v1 region_props[T210_FLCN_ACR_MAX_REGIONS];
109};
110
111struct flcn_acr_desc_v1 {
112 union {
113 u32 reserved_dmem[(LSF_BOOTSTRAP_OWNER_RESERVED_DMEM_SIZE/4)];
114 } ucode_reserved_space;
115 u32 signatures[4];
116 /*Always 1st*/
117 u32 wpr_region_id;
118 u32 wpr_offset;
119 u32 mmu_mem_range;
120 struct flcn_acr_regions_v1 regions;
121 u32 nonwpr_ucode_blob_size;
122 u64 nonwpr_ucode_blob_start;
123 u32 dummy[4]; //ACR_BSI_VPR_DESC
124};
125
126void gp106_init_secure_pmu(struct gpu_ops *gops);
127
128#endif /*__PMU_GP106_H_*/
diff --git a/drivers/gpu/nvgpu/gp106/bios_gp106.c b/drivers/gpu/nvgpu/gp106/bios_gp106.c
new file mode 100644
index 00000000..8be4314d
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/bios_gp106.c
@@ -0,0 +1,121 @@
1/*
2 * Copyright (c) 2015-2016, 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
14#include "gk20a/gk20a.h"
15#include "gm206/bios_gm206.h"
16#include "bios_gp106.h"
17#include "hw_gc6_gp106.h"
18
19static void gp106_init_xmemsel_zm_nv_reg_array(struct gk20a *g, bool *condition,
20 u32 reg, u32 stride, u32 count, u32 data_table_offset)
21{
22 u8 i;
23 u32 data, strap, index;
24
25 if (*condition) {
26
27 strap = gk20a_readl(g, gc6_sci_strap_r()) & 0xf;
28
29 index = g->bios.mem_strap_xlat_tbl_ptr ?
30 gm206_bios_read_u8(g, g->bios.mem_strap_xlat_tbl_ptr +
31 strap) : strap;
32
33 for (i = 0; i < count; i++) {
34 data = gm206_bios_read_u32(g, data_table_offset + ((i *
35 g->bios.mem_strap_data_count + index) *
36 sizeof(u32)));
37 gk20a_writel(g, reg, data);
38 reg += stride;
39 }
40 }
41}
42
43static void gp106_init_condition(struct gk20a *g, bool *condition,
44 u32 condition_id)
45{
46 struct condition_entry entry;
47
48 entry.cond_addr = gm206_bios_read_u32(g, g->bios.condition_table_ptr +
49 sizeof(entry)*condition_id);
50 entry.cond_mask = gm206_bios_read_u32(g, g->bios.condition_table_ptr +
51 sizeof(entry)*condition_id + 4);
52 entry.cond_compare = gm206_bios_read_u32(g, g->bios.condition_table_ptr +
53 sizeof(entry)*condition_id + 8);
54
55 if ((gk20a_readl(g, entry.cond_addr) & entry.cond_mask)
56 != entry.cond_compare) {
57 *condition = false;
58 }
59}
60
61static int gp106_execute_script(struct gk20a *g, u32 offset)
62{
63 u8 opcode;
64 u32 ip;
65 u32 operand[8];
66 bool condition, end;
67 int status = 0;
68
69 ip = offset;
70 condition = true;
71 end = false;
72
73 while (!end) {
74
75 opcode = gm206_bios_read_u8(g, ip++);
76
77 switch (opcode) {
78
79 case INIT_XMEMSEL_ZM_NV_REG_ARRAY:
80 operand[0] = gm206_bios_read_u32(g, ip);
81 operand[1] = gm206_bios_read_u8(g, ip+4);
82 operand[2] = gm206_bios_read_u8(g, ip+5);
83 ip += 6;
84
85 gp106_init_xmemsel_zm_nv_reg_array(g, &condition,
86 operand[0], operand[1], operand[2], ip);
87 ip += operand[2] * sizeof(u32) *
88 g->bios.mem_strap_data_count;
89 break;
90
91 case INIT_CONDITION:
92 operand[0] = gm206_bios_read_u8(g, ip);
93 ip++;
94
95 gp106_init_condition(g, &condition, operand[0]);
96 break;
97
98 case INIT_RESUME:
99 condition = true;
100 break;
101
102 case INIT_DONE:
103 end = true;
104 break;
105
106 default:
107 gk20a_err(dev_from_gk20a(g), "opcode: 0x%02x", opcode);
108 end = true;
109 status = -EINVAL;
110 break;
111 }
112 }
113
114 return status;
115}
116
117void gp106_init_bios(struct gpu_ops *gops)
118{
119 gm206_init_bios(gops);
120 gops->bios.execute_script = gp106_execute_script;
121}
diff --git a/drivers/gpu/nvgpu/gp106/bios_gp106.h b/drivers/gpu/nvgpu/gp106/bios_gp106.h
new file mode 100644
index 00000000..f47d11ca
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/bios_gp106.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright (c) 2016, 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
14#ifndef NVGPU_BIOS_GP106_H
15#define NVGPU_BIOS_GP106_H
16
17struct gpu_ops;
18
19#define INIT_DONE 0x71
20#define INIT_RESUME 0x72
21#define INIT_CONDITION 0x75
22#define INIT_XMEMSEL_ZM_NV_REG_ARRAY 0x8f
23
24struct condition_entry {
25 u32 cond_addr;
26 u32 cond_mask;
27 u32 cond_compare;
28} __packed;
29
30void gp106_init_bios(struct gpu_ops *gops);
31#endif
diff --git a/drivers/gpu/nvgpu/gp106/clk_arb_gp106.c b/drivers/gpu/nvgpu/gp106/clk_arb_gp106.c
new file mode 100644
index 00000000..b4d1afbc
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/clk_arb_gp106.c
@@ -0,0 +1,105 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15
16#include "clk/clk_arb.h"
17#include "clk_arb_gp106.h"
18
19static u32 gp106_get_arbiter_clk_domains(struct gk20a *g)
20{
21 (void)g;
22 return (CTRL_CLK_DOMAIN_MCLK|CTRL_CLK_DOMAIN_GPC2CLK);
23}
24
25static int gp106_get_arbiter_clk_range(struct gk20a *g, u32 api_domain,
26 u16 *min_mhz, u16 *max_mhz)
27{
28 enum nv_pmu_clk_clkwhich clkwhich;
29 struct clk_set_info *p0_info;
30 struct clk_set_info *p5_info;
31 struct avfsfllobjs *pfllobjs = &(g->clk_pmu.avfs_fllobjs);
32
33 u16 limit_min_mhz;
34
35 switch (api_domain) {
36 case CTRL_CLK_DOMAIN_MCLK:
37 clkwhich = clkwhich_mclk;
38 break;
39
40 case CTRL_CLK_DOMAIN_GPC2CLK:
41 clkwhich = clkwhich_gpc2clk;
42 break;
43
44 default:
45 return -EINVAL;
46 }
47
48 p5_info = pstate_get_clk_set_info(g,
49 CTRL_PERF_PSTATE_P5, clkwhich);
50 if (!p5_info)
51 return -EINVAL;
52
53 p0_info = pstate_get_clk_set_info(g,
54 CTRL_PERF_PSTATE_P0, clkwhich);
55 if (!p0_info)
56 return -EINVAL;
57
58 limit_min_mhz = p5_info->min_mhz;
59 /* WAR for DVCO min */
60 if (api_domain == CTRL_CLK_DOMAIN_GPC2CLK)
61 if ((pfllobjs->max_min_freq_mhz) &&
62 (pfllobjs->max_min_freq_mhz > limit_min_mhz))
63 limit_min_mhz = pfllobjs->max_min_freq_mhz;
64
65 *min_mhz = limit_min_mhz;
66 *max_mhz = p0_info->max_mhz;
67
68 return 0;
69}
70
71static int gp106_get_arbiter_clk_default(struct gk20a *g, u32 api_domain,
72 u16 *default_mhz)
73{
74 enum nv_pmu_clk_clkwhich clkwhich;
75 struct clk_set_info *p0_info;
76
77 switch (api_domain) {
78 case CTRL_CLK_DOMAIN_MCLK:
79 clkwhich = clkwhich_mclk;
80 break;
81
82 case CTRL_CLK_DOMAIN_GPC2CLK:
83 clkwhich = clkwhich_gpc2clk;
84 break;
85
86 default:
87 return -EINVAL;
88 }
89
90 p0_info = pstate_get_clk_set_info(g,
91 CTRL_PERF_PSTATE_P0, clkwhich);
92 if (!p0_info)
93 return -EINVAL;
94
95 *default_mhz = p0_info->max_mhz;
96
97 return 0;
98}
99
100void gp106_init_clk_arb_ops(struct gpu_ops *gops)
101{
102 gops->clk_arb.get_arbiter_clk_domains = gp106_get_arbiter_clk_domains;
103 gops->clk_arb.get_arbiter_clk_range = gp106_get_arbiter_clk_range;
104 gops->clk_arb.get_arbiter_clk_default = gp106_get_arbiter_clk_default;
105}
diff --git a/drivers/gpu/nvgpu/gp106/clk_arb_gp106.h b/drivers/gpu/nvgpu/gp106/clk_arb_gp106.h
new file mode 100644
index 00000000..a9877199
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/clk_arb_gp106.h
@@ -0,0 +1,21 @@
1/*
2 * Copyright (c) 2016, 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#ifndef CLK_ARB_GP106_H
17#define CLK_ARB_GP106_H
18
19void gp106_init_clk_arb_ops(struct gpu_ops *gops);
20
21#endif /* CLK_ARB_GP106_H */
diff --git a/drivers/gpu/nvgpu/gp106/clk_gp106.c b/drivers/gpu/nvgpu/gp106/clk_gp106.c
new file mode 100644
index 00000000..4c9bc782
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/clk_gp106.c
@@ -0,0 +1,273 @@
1/*
2 * GP106 Clocks
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/clk.h>
20#include <linux/delay.h> /* for mdelay */
21#include <linux/module.h>
22#include <linux/debugfs.h>
23#include <linux/uaccess.h>
24#include <linux/clk/tegra.h>
25#include <linux/tegra-fuse.h>
26
27#include "gk20a/gk20a.h"
28#include "hw_trim_gp106.h"
29#include "clk_gp106.h"
30#include "clk/clk_arb.h"
31
32#define gk20a_dbg_clk(fmt, arg...) \
33 gk20a_dbg(gpu_dbg_clk, fmt, ##arg)
34
35#ifdef CONFIG_DEBUG_FS
36static int clk_gp106_debugfs_init(struct gk20a *g);
37#endif
38
39#define NUM_NAMEMAPS 4
40#define XTAL4X_KHZ 108000
41
42
43static u32 gp106_get_rate_cntr(struct gk20a *g, struct namemap_cfg *);
44static u16 gp106_clk_get_rate(struct gk20a *g, u32 api_domain);
45static u32 gp106_crystal_clk_hz(struct gk20a *g)
46{
47 return (XTAL4X_KHZ * 1000);
48}
49
50static u16 gp106_clk_get_rate(struct gk20a *g, u32 api_domain)
51{
52 struct clk_gk20a *clk = &g->clk;
53 u32 freq_khz;
54 u32 i;
55 struct namemap_cfg *c = NULL;
56
57 for (i = 0; i < clk->namemap_num; i++) {
58 if (api_domain == clk->namemap_xlat_table[i]) {
59 c = &clk->clk_namemap[i];
60 break;
61 }
62 }
63
64 if (!c)
65 return 0;
66
67 freq_khz = c->is_counter ? c->scale * gp106_get_rate_cntr(g, c) :
68 0; /* TODO: PLL read */
69
70 /* Convert to MHZ */
71 return (u16) (freq_khz/1000);
72}
73
74static int gp106_init_clk_support(struct gk20a *g) {
75 struct clk_gk20a *clk = &g->clk;
76 u32 err = 0;
77
78 gk20a_dbg_fn("");
79
80 mutex_init(&clk->clk_mutex);
81
82 clk->clk_namemap = (struct namemap_cfg *)
83 kzalloc(sizeof(struct namemap_cfg) * NUM_NAMEMAPS, GFP_KERNEL);
84
85 if (!clk->clk_namemap)
86 return -ENOMEM;
87
88 clk->namemap_xlat_table = kcalloc(NUM_NAMEMAPS, sizeof(u32),
89 GFP_KERNEL);
90
91 if (!clk->namemap_xlat_table) {
92 kfree(clk->clk_namemap);
93 return -ENOMEM;
94 }
95
96 clk->clk_namemap[0] = (struct namemap_cfg) {
97 .namemap = CLK_NAMEMAP_INDEX_GPC2CLK,
98 .is_enable = 1,
99 .is_counter = 1,
100 .g = g,
101 .cntr.reg_ctrl_addr = trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_r(),
102 .cntr.reg_ctrl_idx =
103 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_source_gpc2clk_f(),
104 .cntr.reg_cntr_addr = trim_gpc_bcast_clk_cntr_ncgpcclk_cnt_r(),
105 .name = "gpc2clk",
106 .scale = 1
107 };
108 clk->namemap_xlat_table[0] = CTRL_CLK_DOMAIN_GPC2CLK;
109 clk->clk_namemap[1] = (struct namemap_cfg) {
110 .namemap = CLK_NAMEMAP_INDEX_SYS2CLK,
111 .is_enable = 1,
112 .is_counter = 1,
113 .g = g,
114 .cntr.reg_ctrl_addr = trim_sys_clk_cntr_ncsyspll_cfg_r(),
115 .cntr.reg_ctrl_idx = trim_sys_clk_cntr_ncsyspll_cfg_source_sys2clk_f(),
116 .cntr.reg_cntr_addr = trim_sys_clk_cntr_ncsyspll_cnt_r(),
117 .name = "sys2clk",
118 .scale = 1
119 };
120 clk->namemap_xlat_table[1] = CTRL_CLK_DOMAIN_SYS2CLK;
121 clk->clk_namemap[2] = (struct namemap_cfg) {
122 .namemap = CLK_NAMEMAP_INDEX_XBAR2CLK,
123 .is_enable = 1,
124 .is_counter = 1,
125 .g = g,
126 .cntr.reg_ctrl_addr = trim_sys_clk_cntr_ncltcpll_cfg_r(),
127 .cntr.reg_ctrl_idx = trim_sys_clk_cntr_ncltcpll_cfg_source_xbar2clk_f(),
128 .cntr.reg_cntr_addr = trim_sys_clk_cntr_ncltcpll_cnt_r(),
129 .name = "xbar2clk",
130 .scale = 1
131 };
132 clk->namemap_xlat_table[2] = CTRL_CLK_DOMAIN_XBAR2CLK;
133 clk->clk_namemap[3] = (struct namemap_cfg) {
134 .namemap = CLK_NAMEMAP_INDEX_DRAMCLK,
135 .is_enable = 1,
136 .is_counter = 1,
137 .g = g,
138 .cntr.reg_ctrl_addr = trim_fbpa_bcast_clk_cntr_ncltcclk_cfg_r(),
139 .cntr.reg_ctrl_idx =
140 trim_fbpa_bcast_clk_cntr_ncltcclk_cfg_source_dramdiv4_rec_clk1_f(),
141 .cntr.reg_cntr_addr = trim_fbpa_bcast_clk_cntr_ncltcclk_cnt_r(),
142 .name = "dramdiv2_rec_clk1",
143 .scale = 2
144 };
145 clk->namemap_xlat_table[3] = CTRL_CLK_DOMAIN_MCLK;
146
147 clk->namemap_num = NUM_NAMEMAPS;
148
149 clk->g = g;
150
151#ifdef CONFIG_DEBUG_FS
152 if (!clk->debugfs_set) {
153 if (!clk_gp106_debugfs_init(g))
154 clk->debugfs_set = true;
155 }
156#endif
157 return err;
158}
159
160static u32 gp106_get_rate_cntr(struct gk20a *g, struct namemap_cfg *c) {
161 u32 save_reg;
162 u32 retries;
163 u32 cntr = 0;
164
165 struct clk_gk20a *clk = &g->clk;
166
167 if (!c || !c->cntr.reg_ctrl_addr || !c->cntr.reg_cntr_addr)
168 return 0;
169
170 mutex_lock(&clk->clk_mutex);
171
172 /* Save the register */
173 save_reg = gk20a_readl(g, c->cntr.reg_ctrl_addr);
174
175 /* Disable and reset the current clock */
176 gk20a_writel(g, c->cntr.reg_ctrl_addr,
177 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_reset_asserted_f() |
178 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_enable_deasserted_f());
179
180 /* Force wb() */
181 gk20a_readl(g, c->cntr.reg_ctrl_addr);
182
183 /* Wait for reset to happen */
184 retries = CLK_DEFAULT_CNTRL_SETTLE_RETRIES;
185 do {
186 udelay(CLK_DEFAULT_CNTRL_SETTLE_USECS);
187 } while ((--retries) && (cntr = gk20a_readl(g, c->cntr.reg_cntr_addr)));
188
189 if (!retries) {
190 gk20a_err(dev_from_gk20a(g),
191 "unable to settle counter reset, bailing");
192 goto read_err;
193 }
194 /* Program counter */
195 gk20a_writel(g, c->cntr.reg_ctrl_addr,
196 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_reset_deasserted_f() |
197 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_enable_asserted_f() |
198 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_write_en_asserted_f() |
199 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_write_en_asserted_f() |
200 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_write_en_asserted_f() |
201 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_noofipclks_f(XTAL_CNTR_CLKS) |
202 c->cntr.reg_ctrl_idx);
203 gk20a_readl(g, c->cntr.reg_ctrl_addr);
204
205 udelay(XTAL_CNTR_DELAY);
206
207 cntr = XTAL_SCALE_TO_KHZ * gk20a_readl(g, c->cntr.reg_cntr_addr);
208
209read_err:
210 /* reset and restore control register */
211 gk20a_writel(g, c->cntr.reg_ctrl_addr,
212 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_reset_asserted_f() |
213 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_enable_deasserted_f());
214 gk20a_readl(g, c->cntr.reg_ctrl_addr);
215 gk20a_writel(g, c->cntr.reg_ctrl_addr, save_reg);
216 gk20a_readl(g, c->cntr.reg_ctrl_addr);
217 mutex_unlock(&clk->clk_mutex);
218
219 return cntr;
220
221}
222
223#ifdef CONFIG_DEBUG_FS
224static int gp106_get_rate_show(void *data , u64 *val) {
225 struct namemap_cfg *c = (struct namemap_cfg *) data;
226 struct gk20a *g = c->g;
227
228 *val = c->is_counter ? gp106_get_rate_cntr(g, c) : 0 /* TODO PLL read */;
229 return 0;
230}
231DEFINE_SIMPLE_ATTRIBUTE(get_rate_fops, gp106_get_rate_show, NULL, "%llu\n");
232
233
234static int clk_gp106_debugfs_init(struct gk20a *g) {
235 struct gk20a_platform *platform = dev_get_drvdata(g->dev);
236
237 struct dentry *gpu_root = platform->debugfs;
238 struct dentry *clocks_root;
239 struct dentry *d;
240 unsigned int i;
241
242 if (NULL == (clocks_root = debugfs_create_dir("clocks", gpu_root)))
243 return -ENOMEM;
244
245 gk20a_dbg(gpu_dbg_info, "g=%p", g);
246
247 for (i = 0; i < g->clk.namemap_num; i++) {
248 if (g->clk.clk_namemap[i].is_enable) {
249 d = debugfs_create_file(
250 g->clk.clk_namemap[i].name,
251 S_IRUGO,
252 clocks_root,
253 &g->clk.clk_namemap[i],
254 &get_rate_fops);
255 if (!d)
256 goto err_out;
257 }
258 }
259 return 0;
260
261err_out:
262 pr_err("%s: Failed to make debugfs node\n", __func__);
263 debugfs_remove_recursive(clocks_root);
264 return -ENOMEM;
265}
266#endif /* CONFIG_DEBUG_FS */
267
268void gp106_init_clk_ops(struct gpu_ops *gops) {
269 gops->clk.init_clk_support = gp106_init_clk_support;
270 gops->clk.get_crystal_clk_hz = gp106_crystal_clk_hz;
271 gops->clk.get_rate = gp106_clk_get_rate;
272}
273
diff --git a/drivers/gpu/nvgpu/gp106/clk_gp106.h b/drivers/gpu/nvgpu/gp106/clk_gp106.h
new file mode 100644
index 00000000..7df4b974
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/clk_gp106.h
@@ -0,0 +1,56 @@
1/*
2 * Copyright (c) 2016, 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#ifndef CLK_GP106_H
17#define CLK_GP106_H
18
19#include <linux/mutex.h>
20
21#define CLK_NAMEMAP_INDEX_GPC2CLK 0x00
22#define CLK_NAMEMAP_INDEX_XBAR2CLK 0x02
23#define CLK_NAMEMAP_INDEX_SYS2CLK 0x07 /* SYSPLL */
24#define CLK_NAMEMAP_INDEX_DRAMCLK 0x20 /* DRAMPLL */
25
26#define CLK_DEFAULT_CNTRL_SETTLE_RETRIES 10
27#define CLK_DEFAULT_CNTRL_SETTLE_USECS 5
28
29#define XTAL_CNTR_CLKS 27000 /* 1000usec at 27KHz XTAL */
30#define XTAL_CNTR_DELAY 1000 /* we need acuracy up to the ms */
31#define XTAL_SCALE_TO_KHZ 1
32
33
34
35struct namemap_cfg {
36 u32 namemap;
37 u32 is_enable; /* Namemap enabled */
38 u32 is_counter; /* Using cntr */
39 struct gk20a *g;
40 union {
41 struct {
42 u32 reg_ctrl_addr;
43 u32 reg_ctrl_idx;
44 u32 reg_cntr_addr;
45 } cntr;
46 struct {
47 /* Todo */
48 } pll;
49 };
50 u32 scale;
51 char name[24];
52};
53
54void gp106_init_clk_ops(struct gpu_ops *gops);
55
56#endif /* CLK_GP106_H */
diff --git a/drivers/gpu/nvgpu/gp106/fb_gp106.c b/drivers/gpu/nvgpu/gp106/fb_gp106.c
new file mode 100644
index 00000000..ef9f1094
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/fb_gp106.c
@@ -0,0 +1,44 @@
1/*
2 * Copyright (c) 2016, 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
14#include <linux/types.h>
15#include <linux/delay.h>
16
17#include "gk20a/gk20a.h"
18#include "gp10b/fb_gp10b.h"
19#include "hw_fb_gp106.h"
20
21#define HW_SCRUB_TIMEOUT_DEFAULT 100 /* usec */
22#define HW_SCRUB_TIMEOUT_MAX 2000000 /* usec */
23
24static void gp106_fb_reset(struct gk20a *g)
25{
26 int retries = HW_SCRUB_TIMEOUT_MAX / HW_SCRUB_TIMEOUT_DEFAULT;
27 /* wait for memory to be accessible */
28 do {
29 u32 w = gk20a_readl(g, fb_niso_scrub_status_r());
30 if (fb_niso_scrub_status_flag_v(w)) {
31 gk20a_dbg_fn("done");
32 break;
33 }
34 udelay(HW_SCRUB_TIMEOUT_DEFAULT);
35 } while (--retries);
36}
37
38void gp106_init_fb(struct gpu_ops *gops)
39{
40 gp10b_init_fb(gops);
41
42 gops->fb.init_fs_state = NULL;
43 gops->fb.reset = gp106_fb_reset;
44}
diff --git a/drivers/gpu/nvgpu/gp106/fb_gp106.h b/drivers/gpu/nvgpu/gp106/fb_gp106.h
new file mode 100644
index 00000000..87b371e1
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/fb_gp106.h
@@ -0,0 +1,19 @@
1/*
2 * Copyright (c) 2016, 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
14#ifndef FB_GP106_H
15#define FB_GP106_H
16struct gpu_ops;
17
18void gp106_init_fb(struct gpu_ops *gops);
19#endif
diff --git a/drivers/gpu/nvgpu/gp106/fifo_gp106.c b/drivers/gpu/nvgpu/gp106/fifo_gp106.c
new file mode 100644
index 00000000..3c70d517
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/fifo_gp106.c
@@ -0,0 +1,30 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "gp10b/fifo_gp10b.h"
16#include "fifo_gp106.h"
17#include "hw_ccsr_gp106.h"
18#include "hw_fifo_gp106.h"
19
20static u32 gp106_fifo_get_num_fifos(struct gk20a *g)
21{
22 return ccsr_channel__size_1_v();
23}
24
25void gp106_init_fifo(struct gpu_ops *gops)
26{
27 gp10b_init_fifo(gops);
28 gops->fifo.get_num_fifos = gp106_fifo_get_num_fifos;
29 gops->fifo.eng_runlist_base_size = fifo_eng_runlist_base__size_1_v;
30}
diff --git a/drivers/gpu/nvgpu/gp106/fifo_gp106.h b/drivers/gpu/nvgpu/gp106/fifo_gp106.h
new file mode 100644
index 00000000..1bcec9ef
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/fifo_gp106.h
@@ -0,0 +1,18 @@
1/*
2 * Copyright (c) 2016, 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
14#ifndef NVGPU_FIFO_GP106_H
15#define NVGPU_FIFO_GP106_H
16struct gpu_ops;
17void gp106_init_fifo(struct gpu_ops *gops);
18#endif
diff --git a/drivers/gpu/nvgpu/gp106/gp106_gating_reglist.c b/drivers/gpu/nvgpu/gp106/gp106_gating_reglist.c
new file mode 100644
index 00000000..29870d60
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/gp106_gating_reglist.c
@@ -0,0 +1,649 @@
1/*
2 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License.
7 *
8 * This program is distributed in the hope that 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 * This file is autogenerated. Do not edit.
14 */
15
16#ifndef __gp106_gating_reglist_h__
17#define __gp106_gating_reglist_h__
18
19#include <linux/types.h>
20#include "gp106_gating_reglist.h"
21
22struct gating_desc {
23 u32 addr;
24 u32 prod;
25 u32 disable;
26};
27/* slcg bus */
28static const struct gating_desc gp106_slcg_bus[] = {
29 {.addr = 0x00001c04, .prod = 0x00000000, .disable = 0x000003fe},
30};
31
32/* slcg ce2 */
33static const struct gating_desc gp106_slcg_ce2[] = {
34 {.addr = 0x00104204, .prod = 0x00000000, .disable = 0x000007fe},
35};
36
37/* slcg chiplet */
38static const struct gating_desc gp106_slcg_chiplet[] = {
39 {.addr = 0x0010c07c, .prod = 0x00000000, .disable = 0x00000007},
40 {.addr = 0x0010c0fc, .prod = 0x00000000, .disable = 0x00000007},
41 {.addr = 0x0010c17c, .prod = 0x00000000, .disable = 0x00000007},
42 {.addr = 0x0010c1fc, .prod = 0x00000000, .disable = 0x00000007},
43 {.addr = 0x0010c27c, .prod = 0x00000000, .disable = 0x00000007},
44 {.addr = 0x0010c2fc, .prod = 0x00000000, .disable = 0x00000007},
45 {.addr = 0x0010e07c, .prod = 0x00000000, .disable = 0x00000007},
46 {.addr = 0x0010d07c, .prod = 0x00000000, .disable = 0x00000007},
47 {.addr = 0x0010d0fc, .prod = 0x00000000, .disable = 0x00000007},
48 {.addr = 0x0010d17c, .prod = 0x00000000, .disable = 0x00000007},
49 {.addr = 0x0010d1fc, .prod = 0x00000000, .disable = 0x00000007},
50 {.addr = 0x0010d27c, .prod = 0x00000000, .disable = 0x00000007},
51 {.addr = 0x0010d2fc, .prod = 0x00000000, .disable = 0x00000007},
52 {.addr = 0x0010e17c, .prod = 0x00000000, .disable = 0x00000007},
53};
54
55/* slcg fb */
56static const struct gating_desc gp106_slcg_fb[] = {
57 {.addr = 0x00100d14, .prod = 0x00000000, .disable = 0xfffffffe},
58 {.addr = 0x00100c9c, .prod = 0x00000000, .disable = 0x000001fe},
59};
60
61/* slcg fifo */
62static const struct gating_desc gp106_slcg_fifo[] = {
63 {.addr = 0x000026ac, .prod = 0x00000000, .disable = 0x0001fffe},
64};
65
66/* slcg gr */
67static const struct gating_desc gp106_slcg_gr[] = {
68 {.addr = 0x004041f4, .prod = 0x00000000, .disable = 0x07fffffe},
69 {.addr = 0x0040917c, .prod = 0x00020008, .disable = 0x0003fffe},
70 {.addr = 0x00409894, .prod = 0x00000040, .disable = 0x03fffffe},
71 {.addr = 0x004078c4, .prod = 0x00000000, .disable = 0x000001fe},
72 {.addr = 0x00406004, .prod = 0x00000000, .disable = 0x0001fffe},
73 {.addr = 0x00405864, .prod = 0x00000000, .disable = 0x000001fe},
74 {.addr = 0x00405910, .prod = 0xfffffff0, .disable = 0xfffffffe},
75 {.addr = 0x00408044, .prod = 0x00000000, .disable = 0x000007fe},
76 {.addr = 0x00407004, .prod = 0x00000000, .disable = 0x000001fe},
77 {.addr = 0x0041a17c, .prod = 0x00020008, .disable = 0x0003fffe},
78 {.addr = 0x0041a894, .prod = 0x00000040, .disable = 0x03fffffe},
79 {.addr = 0x00418504, .prod = 0x00000000, .disable = 0x0007fffe},
80 {.addr = 0x0041860c, .prod = 0x00000000, .disable = 0x000001fe},
81 {.addr = 0x0041868c, .prod = 0x00000000, .disable = 0x0000001e},
82 {.addr = 0x0041871c, .prod = 0x00000000, .disable = 0x000003fe},
83 {.addr = 0x00418388, .prod = 0x00000000, .disable = 0x00000001},
84 {.addr = 0x0041882c, .prod = 0x00000000, .disable = 0x0001fffe},
85 {.addr = 0x00418bc0, .prod = 0x00000000, .disable = 0x000001fe},
86 {.addr = 0x00418974, .prod = 0x00000000, .disable = 0x0001fffe},
87 {.addr = 0x00418c74, .prod = 0xffffff80, .disable = 0xfffffffe},
88 {.addr = 0x00418cf4, .prod = 0xfffffff8, .disable = 0xfffffffe},
89 {.addr = 0x00418d74, .prod = 0xffffffe0, .disable = 0xfffffffe},
90 {.addr = 0x00418f10, .prod = 0xffffffe0, .disable = 0xfffffffe},
91 {.addr = 0x00418e10, .prod = 0xfffffffe, .disable = 0xfffffffe},
92 {.addr = 0x00419024, .prod = 0x000001fe, .disable = 0x000001fe},
93 {.addr = 0x0041889c, .prod = 0x00000000, .disable = 0x000001fe},
94 {.addr = 0x00419d24, .prod = 0x00000000, .disable = 0x0000ffff},
95 {.addr = 0x00419a44, .prod = 0x00000000, .disable = 0x0000000e},
96 {.addr = 0x00419a4c, .prod = 0x00000000, .disable = 0x000001fe},
97 {.addr = 0x00419a54, .prod = 0x00000000, .disable = 0x0000003e},
98 {.addr = 0x00419a5c, .prod = 0x00000000, .disable = 0x0000000e},
99 {.addr = 0x00419a64, .prod = 0x00000000, .disable = 0x000001fe},
100 {.addr = 0x00419a6c, .prod = 0x00000000, .disable = 0x0000000e},
101 {.addr = 0x00419a74, .prod = 0x00000000, .disable = 0x0000000e},
102 {.addr = 0x00419a7c, .prod = 0x00000000, .disable = 0x0000003e},
103 {.addr = 0x00419a84, .prod = 0x00000000, .disable = 0x0000000e},
104 {.addr = 0x0041986c, .prod = 0x00000104, .disable = 0x00fffffe},
105 {.addr = 0x00419cd8, .prod = 0x00000000, .disable = 0x001ffffe},
106 {.addr = 0x00419ce0, .prod = 0x00000000, .disable = 0x001ffffe},
107 {.addr = 0x00419c74, .prod = 0x0000001e, .disable = 0x0000001e},
108 {.addr = 0x00419fd4, .prod = 0x00000000, .disable = 0x0003fffe},
109 {.addr = 0x00419fdc, .prod = 0xffedff00, .disable = 0xfffffffe},
110 {.addr = 0x00419fe4, .prod = 0x00001b00, .disable = 0x00001ffe},
111 {.addr = 0x00419ff4, .prod = 0x00000000, .disable = 0x00003ffe},
112 {.addr = 0x00419ffc, .prod = 0x00000000, .disable = 0x0001fffe},
113 {.addr = 0x0041be2c, .prod = 0x04115fc0, .disable = 0xfffffffe},
114 {.addr = 0x0041bfec, .prod = 0xfffffff0, .disable = 0xfffffffe},
115 {.addr = 0x0041bed4, .prod = 0xfffffff8, .disable = 0xfffffffe},
116 {.addr = 0x00412814, .prod = 0x00000000, .disable = 0x0001fffe},
117 {.addr = 0x00412a84, .prod = 0x00000000, .disable = 0x0001fffe},
118 {.addr = 0x004129ac, .prod = 0x00000000, .disable = 0x0001fffe},
119 {.addr = 0x00412a24, .prod = 0x00000000, .disable = 0x0000ffff},
120 {.addr = 0x00412c14, .prod = 0x00000000, .disable = 0x0001fffe},
121 {.addr = 0x00412e84, .prod = 0x00000000, .disable = 0x0001fffe},
122 {.addr = 0x00412dac, .prod = 0x00000000, .disable = 0x0001fffe},
123 {.addr = 0x00412e24, .prod = 0x00000000, .disable = 0x0000ffff},
124 {.addr = 0x00408814, .prod = 0x00000000, .disable = 0x0001fffe},
125 {.addr = 0x00408a84, .prod = 0x00000000, .disable = 0x0001fffe},
126 {.addr = 0x004089ac, .prod = 0x00000000, .disable = 0x0001fffe},
127 {.addr = 0x00408a24, .prod = 0x00000000, .disable = 0x0000ffff},
128};
129
130/* slcg ltc */
131static const struct gating_desc gp106_slcg_ltc[] = {
132 {.addr = 0x00154050, .prod = 0x00000000, .disable = 0xfffffffe},
133 {.addr = 0x0015455c, .prod = 0x00000000, .disable = 0xfffffffe},
134 {.addr = 0x0015475c, .prod = 0x00000000, .disable = 0xfffffffe},
135 {.addr = 0x0015435c, .prod = 0x00000000, .disable = 0xfffffffe},
136 {.addr = 0x00156050, .prod = 0x00000000, .disable = 0xfffffffe},
137 {.addr = 0x0015655c, .prod = 0x00000000, .disable = 0xfffffffe},
138 {.addr = 0x0015675c, .prod = 0x00000000, .disable = 0xfffffffe},
139 {.addr = 0x0015635c, .prod = 0x00000000, .disable = 0xfffffffe},
140 {.addr = 0x0017e050, .prod = 0x00000000, .disable = 0xfffffffe},
141 {.addr = 0x0017e35c, .prod = 0x00000000, .disable = 0xfffffffe},
142};
143
144/* slcg perf */
145static const struct gating_desc gp106_slcg_perf[] = {
146 {.addr = 0x001be018, .prod = 0x000001ff, .disable = 0x00000000},
147 {.addr = 0x001bc018, .prod = 0x000001ff, .disable = 0x00000000},
148 {.addr = 0x001bc218, .prod = 0x000001ff, .disable = 0x00000000},
149 {.addr = 0x001bc418, .prod = 0x000001ff, .disable = 0x00000000},
150 {.addr = 0x001bc618, .prod = 0x000001ff, .disable = 0x00000000},
151 {.addr = 0x001bc818, .prod = 0x000001ff, .disable = 0x00000000},
152 {.addr = 0x001bca18, .prod = 0x000001ff, .disable = 0x00000000},
153 {.addr = 0x001b8018, .prod = 0x000001ff, .disable = 0x00000000},
154 {.addr = 0x001b8218, .prod = 0x000001ff, .disable = 0x00000000},
155 {.addr = 0x001b8418, .prod = 0x000001ff, .disable = 0x00000000},
156 {.addr = 0x001b8618, .prod = 0x000001ff, .disable = 0x00000000},
157 {.addr = 0x001b8818, .prod = 0x000001ff, .disable = 0x00000000},
158 {.addr = 0x001b8a18, .prod = 0x000001ff, .disable = 0x00000000},
159 {.addr = 0x001b4124, .prod = 0x00000001, .disable = 0x00000000},
160};
161
162/* slcg PriRing */
163static const struct gating_desc gp106_slcg_priring[] = {
164 {.addr = 0x001200a8, .prod = 0x00000000, .disable = 0x00000001},
165};
166
167/* slcg pmu */
168static const struct gating_desc gp106_slcg_pmu[] = {
169 {.addr = 0x0010a134, .prod = 0x00020008, .disable = 0x0003fffe},
170 {.addr = 0x0010aa74, .prod = 0x00000000, .disable = 0x00007ffe},
171 {.addr = 0x0010ae74, .prod = 0x00000000, .disable = 0x0000000f},
172};
173
174/* therm gr */
175static const struct gating_desc gp106_slcg_therm[] = {
176 {.addr = 0x000206b8, .prod = 0x00000000, .disable = 0x0000000f},
177};
178
179/* slcg Xbar */
180static const struct gating_desc gp106_slcg_xbar[] = {
181 {.addr = 0x0013c824, .prod = 0x00000000, .disable = 0x7ffffffe},
182 {.addr = 0x0013dc08, .prod = 0x00000000, .disable = 0xfffffffe},
183 {.addr = 0x0013c924, .prod = 0x00000000, .disable = 0x7ffffffe},
184 {.addr = 0x0013cbe4, .prod = 0x00000000, .disable = 0x1ffffffe},
185 {.addr = 0x0013cc04, .prod = 0x00000000, .disable = 0x1ffffffe},
186 {.addr = 0x0013cc24, .prod = 0x00000000, .disable = 0x1ffffffe},
187 {.addr = 0x0013cc44, .prod = 0x00000000, .disable = 0x1ffffffe},
188 {.addr = 0x0013cc64, .prod = 0x00000000, .disable = 0x1ffffffe},
189 {.addr = 0x0013cc84, .prod = 0x00000000, .disable = 0x1ffffffe},
190 {.addr = 0x0013cca4, .prod = 0x00000000, .disable = 0x1ffffffe},
191};
192
193/* blcg bus */
194static const struct gating_desc gp106_blcg_bus[] = {
195 {.addr = 0x00001c00, .prod = 0x00000042, .disable = 0x00000000},
196};
197
198/* blcg ce */
199static const struct gating_desc gp106_blcg_ce[] = {
200 {.addr = 0x00104200, .prod = 0x0000c242, .disable = 0x00000000},
201};
202
203/* blcg fb */
204static const struct gating_desc gp106_blcg_fb[] = {
205 {.addr = 0x00100d10, .prod = 0x0000c242, .disable = 0x00000000},
206 {.addr = 0x00100d30, .prod = 0x0000c242, .disable = 0x00000000},
207 {.addr = 0x00100d3c, .prod = 0x00000242, .disable = 0x00000000},
208 {.addr = 0x00100d48, .prod = 0x0000c242, .disable = 0x00000000},
209 {.addr = 0x00100d1c, .prod = 0x00000042, .disable = 0x00000000},
210 {.addr = 0x00100c98, .prod = 0x00004242, .disable = 0x00000000},
211};
212
213/* blcg fifo */
214static const struct gating_desc gp106_blcg_fifo[] = {
215 {.addr = 0x000026a4, .prod = 0x0000c242, .disable = 0x00000000},
216};
217
218/* blcg gr */
219static const struct gating_desc gp106_blcg_gr[] = {
220 {.addr = 0x004041f0, .prod = 0x0000c646, .disable = 0x00000000},
221 {.addr = 0x00409890, .prod = 0x0000007f, .disable = 0x00000000},
222 {.addr = 0x004098b0, .prod = 0x0000007f, .disable = 0x00000000},
223 {.addr = 0x004078c0, .prod = 0x00004242, .disable = 0x00000000},
224 {.addr = 0x00406000, .prod = 0x0000c444, .disable = 0x00000000},
225 {.addr = 0x00405860, .prod = 0x0000c242, .disable = 0x00000000},
226 {.addr = 0x0040590c, .prod = 0x0000c444, .disable = 0x00000000},
227 {.addr = 0x00408040, .prod = 0x0000c444, .disable = 0x00000000},
228 {.addr = 0x00407000, .prod = 0x4000c242, .disable = 0x00000000},
229 {.addr = 0x00405bf0, .prod = 0x0000c444, .disable = 0x00000000},
230 {.addr = 0x0041a890, .prod = 0x0000427f, .disable = 0x00000000},
231 {.addr = 0x0041a8b0, .prod = 0x0000007f, .disable = 0x00000000},
232 {.addr = 0x00418500, .prod = 0x0000c244, .disable = 0x00000000},
233 {.addr = 0x00418608, .prod = 0x0000c242, .disable = 0x00000000},
234 {.addr = 0x00418688, .prod = 0x0000c242, .disable = 0x00000000},
235 {.addr = 0x00418718, .prod = 0x00000042, .disable = 0x00000000},
236 {.addr = 0x00418828, .prod = 0x00008444, .disable = 0x00000000},
237 {.addr = 0x00418bbc, .prod = 0x0000c242, .disable = 0x00000000},
238 {.addr = 0x00418970, .prod = 0x0000c242, .disable = 0x00000000},
239 {.addr = 0x00418c70, .prod = 0x0000c444, .disable = 0x00000000},
240 {.addr = 0x00418cf0, .prod = 0x0000c444, .disable = 0x00000000},
241 {.addr = 0x00418d70, .prod = 0x0000c444, .disable = 0x00000000},
242 {.addr = 0x00418f0c, .prod = 0x0000c444, .disable = 0x00000000},
243 {.addr = 0x00418e0c, .prod = 0x00008444, .disable = 0x00000000},
244 {.addr = 0x00419020, .prod = 0x0000c242, .disable = 0x00000000},
245 {.addr = 0x00419038, .prod = 0x00000042, .disable = 0x00000000},
246 {.addr = 0x00418898, .prod = 0x00004242, .disable = 0x00000000},
247 {.addr = 0x00419a40, .prod = 0x0000c242, .disable = 0x00000000},
248 {.addr = 0x00419a48, .prod = 0x0000c242, .disable = 0x00000000},
249 {.addr = 0x00419a50, .prod = 0x0000c242, .disable = 0x00000000},
250 {.addr = 0x00419a58, .prod = 0x0000c242, .disable = 0x00000000},
251 {.addr = 0x00419a60, .prod = 0x0000c242, .disable = 0x00000000},
252 {.addr = 0x00419a68, .prod = 0x0000c242, .disable = 0x00000000},
253 {.addr = 0x00419a70, .prod = 0x0000c242, .disable = 0x00000000},
254 {.addr = 0x00419a78, .prod = 0x0000c242, .disable = 0x00000000},
255 {.addr = 0x00419a80, .prod = 0x0000c242, .disable = 0x00000000},
256 {.addr = 0x00419868, .prod = 0x00008242, .disable = 0x00000000},
257 {.addr = 0x00419cd4, .prod = 0x00000002, .disable = 0x00000000},
258 {.addr = 0x00419cdc, .prod = 0x00000002, .disable = 0x00000000},
259 {.addr = 0x00419c70, .prod = 0x0000c444, .disable = 0x00000000},
260 {.addr = 0x00419fd0, .prod = 0x0000c044, .disable = 0x00000000},
261 {.addr = 0x00419fd8, .prod = 0x0000c046, .disable = 0x00000000},
262 {.addr = 0x00419fe0, .prod = 0x0000c044, .disable = 0x00000000},
263 {.addr = 0x00419fe8, .prod = 0x0000c042, .disable = 0x00000000},
264 {.addr = 0x00419ff0, .prod = 0x0000c045, .disable = 0x00000000},
265 {.addr = 0x00419ff8, .prod = 0x00000002, .disable = 0x00000000},
266 {.addr = 0x00419f90, .prod = 0x00000002, .disable = 0x00000000},
267 {.addr = 0x0041be28, .prod = 0x00008242, .disable = 0x00000000},
268 {.addr = 0x0041bfe8, .prod = 0x0000c444, .disable = 0x00000000},
269 {.addr = 0x0041bed0, .prod = 0x0000c444, .disable = 0x00000000},
270 {.addr = 0x00412810, .prod = 0x0000c242, .disable = 0x00000000},
271 {.addr = 0x00412a80, .prod = 0x0000c242, .disable = 0x00000000},
272 {.addr = 0x004129a8, .prod = 0x0000c242, .disable = 0x00000000},
273 {.addr = 0x00412c10, .prod = 0x0000c242, .disable = 0x00000000},
274 {.addr = 0x00412e80, .prod = 0x0000c242, .disable = 0x00000000},
275 {.addr = 0x00412da8, .prod = 0x0000c242, .disable = 0x00000000},
276 {.addr = 0x00408810, .prod = 0x0000c242, .disable = 0x00000000},
277 {.addr = 0x00408a80, .prod = 0x0000c242, .disable = 0x00000000},
278 {.addr = 0x004089a8, .prod = 0x0000c242, .disable = 0x00000000},
279};
280
281/* blcg ltc */
282static const struct gating_desc gp106_blcg_ltc[] = {
283 {.addr = 0x00154030, .prod = 0x00000044, .disable = 0x00000000},
284 {.addr = 0x00154040, .prod = 0x00000044, .disable = 0x00000000},
285 {.addr = 0x001545e0, .prod = 0x00000044, .disable = 0x00000000},
286 {.addr = 0x001545c8, .prod = 0x00000044, .disable = 0x00000000},
287 {.addr = 0x001547e0, .prod = 0x00000044, .disable = 0x00000000},
288 {.addr = 0x001547c8, .prod = 0x00000044, .disable = 0x00000000},
289 {.addr = 0x001543e0, .prod = 0x00000044, .disable = 0x00000000},
290 {.addr = 0x001543c8, .prod = 0x00000044, .disable = 0x00000000},
291 {.addr = 0x00156030, .prod = 0x00000044, .disable = 0x00000000},
292 {.addr = 0x00156040, .prod = 0x00000044, .disable = 0x00000000},
293 {.addr = 0x001565e0, .prod = 0x00000044, .disable = 0x00000000},
294 {.addr = 0x001565c8, .prod = 0x00000044, .disable = 0x00000000},
295 {.addr = 0x001567e0, .prod = 0x00000044, .disable = 0x00000000},
296 {.addr = 0x001567c8, .prod = 0x00000044, .disable = 0x00000000},
297 {.addr = 0x001563e0, .prod = 0x00000044, .disable = 0x00000000},
298 {.addr = 0x001563c8, .prod = 0x00000044, .disable = 0x00000000},
299 {.addr = 0x0017e030, .prod = 0x00000044, .disable = 0x00000000},
300 {.addr = 0x0017e040, .prod = 0x00000044, .disable = 0x00000000},
301 {.addr = 0x0017e3e0, .prod = 0x00000044, .disable = 0x00000000},
302 {.addr = 0x0017e3c8, .prod = 0x00000044, .disable = 0x00000000},
303};
304
305/* blcg pmu */
306static const struct gating_desc gp106_blcg_pmu[] = {
307 {.addr = 0x0010aa70, .prod = 0x00000045, .disable = 0x00000000},
308};
309
310/* blcg Xbar */
311static const struct gating_desc gp106_blcg_xbar[] = {
312 {.addr = 0x0013c820, .prod = 0x0001004a, .disable = 0x00000000},
313 {.addr = 0x0013dc04, .prod = 0x0001004a, .disable = 0x00000000},
314 {.addr = 0x0013c920, .prod = 0x0000004a, .disable = 0x00000000},
315 {.addr = 0x0013cbe0, .prod = 0x00000042, .disable = 0x00000000},
316 {.addr = 0x0013cc00, .prod = 0x00000042, .disable = 0x00000000},
317 {.addr = 0x0013cc20, .prod = 0x00000042, .disable = 0x00000000},
318 {.addr = 0x0013cc40, .prod = 0x00000042, .disable = 0x00000000},
319 {.addr = 0x0013cc60, .prod = 0x00000042, .disable = 0x00000000},
320 {.addr = 0x0013cc80, .prod = 0x00000042, .disable = 0x00000000},
321 {.addr = 0x0013cca0, .prod = 0x00000042, .disable = 0x00000000},
322};
323
324/* pg gr */
325static const struct gating_desc gp106_pg_gr[] = {
326};
327
328/* inline functions */
329void gp106_slcg_bus_load_gating_prod(struct gk20a *g,
330 bool prod)
331{
332 u32 i;
333 u32 size = sizeof(gp106_slcg_bus) / sizeof(struct gating_desc);
334 for (i = 0; i < size; i++) {
335 if (prod)
336 gk20a_writel(g, gp106_slcg_bus[i].addr,
337 gp106_slcg_bus[i].prod);
338 else
339 gk20a_writel(g, gp106_slcg_bus[i].addr,
340 gp106_slcg_bus[i].disable);
341 }
342}
343
344void gp106_slcg_ce2_load_gating_prod(struct gk20a *g,
345 bool prod)
346{
347 u32 i;
348 u32 size = sizeof(gp106_slcg_ce2) / sizeof(struct gating_desc);
349 for (i = 0; i < size; i++) {
350 if (prod)
351 gk20a_writel(g, gp106_slcg_ce2[i].addr,
352 gp106_slcg_ce2[i].prod);
353 else
354 gk20a_writel(g, gp106_slcg_ce2[i].addr,
355 gp106_slcg_ce2[i].disable);
356 }
357}
358
359void gp106_slcg_chiplet_load_gating_prod(struct gk20a *g,
360 bool prod)
361{
362 u32 i;
363 u32 size = sizeof(gp106_slcg_chiplet) / sizeof(struct gating_desc);
364 for (i = 0; i < size; i++) {
365 if (prod)
366 gk20a_writel(g, gp106_slcg_chiplet[i].addr,
367 gp106_slcg_chiplet[i].prod);
368 else
369 gk20a_writel(g, gp106_slcg_chiplet[i].addr,
370 gp106_slcg_chiplet[i].disable);
371 }
372}
373
374void gp106_slcg_ctxsw_firmware_load_gating_prod(struct gk20a *g,
375 bool prod)
376{
377}
378
379void gp106_slcg_fb_load_gating_prod(struct gk20a *g,
380 bool prod)
381{
382 u32 i;
383 u32 size = sizeof(gp106_slcg_fb) / sizeof(struct gating_desc);
384 for (i = 0; i < size; i++) {
385 if (prod)
386 gk20a_writel(g, gp106_slcg_fb[i].addr,
387 gp106_slcg_fb[i].prod);
388 else
389 gk20a_writel(g, gp106_slcg_fb[i].addr,
390 gp106_slcg_fb[i].disable);
391 }
392}
393
394void gp106_slcg_fifo_load_gating_prod(struct gk20a *g,
395 bool prod)
396{
397 u32 i;
398 u32 size = sizeof(gp106_slcg_fifo) / sizeof(struct gating_desc);
399 for (i = 0; i < size; i++) {
400 if (prod)
401 gk20a_writel(g, gp106_slcg_fifo[i].addr,
402 gp106_slcg_fifo[i].prod);
403 else
404 gk20a_writel(g, gp106_slcg_fifo[i].addr,
405 gp106_slcg_fifo[i].disable);
406 }
407}
408
409void gr_gp106_slcg_gr_load_gating_prod(struct gk20a *g,
410 bool prod)
411{
412 u32 i;
413 u32 size = sizeof(gp106_slcg_gr) / sizeof(struct gating_desc);
414 for (i = 0; i < size; i++) {
415 if (prod)
416 gk20a_writel(g, gp106_slcg_gr[i].addr,
417 gp106_slcg_gr[i].prod);
418 else
419 gk20a_writel(g, gp106_slcg_gr[i].addr,
420 gp106_slcg_gr[i].disable);
421 }
422}
423
424void ltc_gp106_slcg_ltc_load_gating_prod(struct gk20a *g,
425 bool prod)
426{
427 u32 i;
428 u32 size = sizeof(gp106_slcg_ltc) / sizeof(struct gating_desc);
429 for (i = 0; i < size; i++) {
430 if (prod)
431 gk20a_writel(g, gp106_slcg_ltc[i].addr,
432 gp106_slcg_ltc[i].prod);
433 else
434 gk20a_writel(g, gp106_slcg_ltc[i].addr,
435 gp106_slcg_ltc[i].disable);
436 }
437}
438
439void gp106_slcg_perf_load_gating_prod(struct gk20a *g,
440 bool prod)
441{
442 u32 i;
443 u32 size = sizeof(gp106_slcg_perf) / sizeof(struct gating_desc);
444 for (i = 0; i < size; i++) {
445 if (prod)
446 gk20a_writel(g, gp106_slcg_perf[i].addr,
447 gp106_slcg_perf[i].prod);
448 else
449 gk20a_writel(g, gp106_slcg_perf[i].addr,
450 gp106_slcg_perf[i].disable);
451 }
452}
453
454void gp106_slcg_priring_load_gating_prod(struct gk20a *g,
455 bool prod)
456{
457 u32 i;
458 u32 size = sizeof(gp106_slcg_priring) / sizeof(struct gating_desc);
459 for (i = 0; i < size; i++) {
460 if (prod)
461 gk20a_writel(g, gp106_slcg_priring[i].addr,
462 gp106_slcg_priring[i].prod);
463 else
464 gk20a_writel(g, gp106_slcg_priring[i].addr,
465 gp106_slcg_priring[i].disable);
466 }
467}
468
469void gp106_slcg_pmu_load_gating_prod(struct gk20a *g,
470 bool prod)
471{
472 u32 i;
473 u32 size = sizeof(gp106_slcg_pmu) / sizeof(struct gating_desc);
474 for (i = 0; i < size; i++) {
475 if (prod)
476 gk20a_writel(g, gp106_slcg_pmu[i].addr,
477 gp106_slcg_pmu[i].prod);
478 else
479 gk20a_writel(g, gp106_slcg_pmu[i].addr,
480 gp106_slcg_pmu[i].disable);
481 }
482}
483
484void gp106_slcg_therm_load_gating_prod(struct gk20a *g,
485 bool prod)
486{
487 u32 i;
488 u32 size = sizeof(gp106_slcg_therm) / sizeof(struct gating_desc);
489 for (i = 0; i < size; i++) {
490 if (prod)
491 gk20a_writel(g, gp106_slcg_therm[i].addr,
492 gp106_slcg_therm[i].prod);
493 else
494 gk20a_writel(g, gp106_slcg_therm[i].addr,
495 gp106_slcg_therm[i].disable);
496 }
497}
498
499void gp106_slcg_xbar_load_gating_prod(struct gk20a *g,
500 bool prod)
501{
502 u32 i;
503 u32 size = sizeof(gp106_slcg_xbar) / sizeof(struct gating_desc);
504 for (i = 0; i < size; i++) {
505 if (prod)
506 gk20a_writel(g, gp106_slcg_xbar[i].addr,
507 gp106_slcg_xbar[i].prod);
508 else
509 gk20a_writel(g, gp106_slcg_xbar[i].addr,
510 gp106_slcg_xbar[i].disable);
511 }
512}
513
514void gp106_blcg_bus_load_gating_prod(struct gk20a *g,
515 bool prod)
516{
517 u32 i;
518 u32 size = sizeof(gp106_blcg_bus) / sizeof(struct gating_desc);
519 for (i = 0; i < size; i++) {
520 if (prod)
521 gk20a_writel(g, gp106_blcg_bus[i].addr,
522 gp106_blcg_bus[i].prod);
523 else
524 gk20a_writel(g, gp106_blcg_bus[i].addr,
525 gp106_blcg_bus[i].disable);
526 }
527}
528
529void gp106_blcg_ce_load_gating_prod(struct gk20a *g,
530 bool prod)
531{
532 u32 i;
533 u32 size = sizeof(gp106_blcg_ce) / sizeof(struct gating_desc);
534 for (i = 0; i < size; i++) {
535 if (prod)
536 gk20a_writel(g, gp106_blcg_ce[i].addr,
537 gp106_blcg_ce[i].prod);
538 else
539 gk20a_writel(g, gp106_blcg_ce[i].addr,
540 gp106_blcg_ce[i].disable);
541 }
542}
543
544void gp106_blcg_fb_load_gating_prod(struct gk20a *g,
545 bool prod)
546{
547 u32 i;
548 u32 size = sizeof(gp106_blcg_fb) / sizeof(struct gating_desc);
549 for (i = 0; i < size; i++) {
550 if (prod)
551 gk20a_writel(g, gp106_blcg_fb[i].addr,
552 gp106_blcg_fb[i].prod);
553 else
554 gk20a_writel(g, gp106_blcg_fb[i].addr,
555 gp106_blcg_fb[i].disable);
556 }
557}
558
559void gp106_blcg_fifo_load_gating_prod(struct gk20a *g,
560 bool prod)
561{
562 u32 i;
563 u32 size = sizeof(gp106_blcg_fifo) / sizeof(struct gating_desc);
564 for (i = 0; i < size; i++) {
565 if (prod)
566 gk20a_writel(g, gp106_blcg_fifo[i].addr,
567 gp106_blcg_fifo[i].prod);
568 else
569 gk20a_writel(g, gp106_blcg_fifo[i].addr,
570 gp106_blcg_fifo[i].disable);
571 }
572}
573
574void gp106_blcg_gr_load_gating_prod(struct gk20a *g,
575 bool prod)
576{
577 u32 i;
578 u32 size = sizeof(gp106_blcg_gr) / sizeof(struct gating_desc);
579 for (i = 0; i < size; i++) {
580 if (prod)
581 gk20a_writel(g, gp106_blcg_gr[i].addr,
582 gp106_blcg_gr[i].prod);
583 else
584 gk20a_writel(g, gp106_blcg_gr[i].addr,
585 gp106_blcg_gr[i].disable);
586 }
587}
588
589void gp106_blcg_ltc_load_gating_prod(struct gk20a *g,
590 bool prod)
591{
592 u32 i;
593 u32 size = sizeof(gp106_blcg_ltc) / sizeof(struct gating_desc);
594 for (i = 0; i < size; i++) {
595 if (prod)
596 gk20a_writel(g, gp106_blcg_ltc[i].addr,
597 gp106_blcg_ltc[i].prod);
598 else
599 gk20a_writel(g, gp106_blcg_ltc[i].addr,
600 gp106_blcg_ltc[i].disable);
601 }
602}
603
604void gp106_blcg_pmu_load_gating_prod(struct gk20a *g,
605 bool prod)
606{
607 u32 i;
608 u32 size = sizeof(gp106_blcg_pmu) / sizeof(struct gating_desc);
609 for (i = 0; i < size; i++) {
610 if (prod)
611 gk20a_writel(g, gp106_blcg_pmu[i].addr,
612 gp106_blcg_pmu[i].prod);
613 else
614 gk20a_writel(g, gp106_blcg_pmu[i].addr,
615 gp106_blcg_pmu[i].disable);
616 }
617}
618
619void gp106_blcg_xbar_load_gating_prod(struct gk20a *g,
620 bool prod)
621{
622 u32 i;
623 u32 size = sizeof(gp106_blcg_xbar) / sizeof(struct gating_desc);
624 for (i = 0; i < size; i++) {
625 if (prod)
626 gk20a_writel(g, gp106_blcg_xbar[i].addr,
627 gp106_blcg_xbar[i].prod);
628 else
629 gk20a_writel(g, gp106_blcg_xbar[i].addr,
630 gp106_blcg_xbar[i].disable);
631 }
632}
633
634void gr_gp106_pg_gr_load_gating_prod(struct gk20a *g,
635 bool prod)
636{
637 u32 i;
638 u32 size = sizeof(gp106_pg_gr) / sizeof(struct gating_desc);
639 for (i = 0; i < size; i++) {
640 if (prod)
641 gk20a_writel(g, gp106_pg_gr[i].addr,
642 gp106_pg_gr[i].prod);
643 else
644 gk20a_writel(g, gp106_pg_gr[i].addr,
645 gp106_pg_gr[i].disable);
646 }
647}
648
649#endif /* __gp106_gating_reglist_h__ */
diff --git a/drivers/gpu/nvgpu/gp106/gp106_gating_reglist.h b/drivers/gpu/nvgpu/gp106/gp106_gating_reglist.h
new file mode 100644
index 00000000..423ccf54
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/gp106_gating_reglist.h
@@ -0,0 +1,87 @@
1/*
2 * Copyright (c) 2015-2016, 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 "gk20a/gk20a.h"
18
19void gp106_slcg_bus_load_gating_prod(struct gk20a *g,
20 bool prod);
21
22void gp106_slcg_ce2_load_gating_prod(struct gk20a *g,
23 bool prod);
24
25void gp106_slcg_chiplet_load_gating_prod(struct gk20a *g,
26 bool prod);
27
28void gp106_slcg_ctxsw_firmware_load_gating_prod(struct gk20a *g,
29 bool prod);
30
31void gp106_slcg_fb_load_gating_prod(struct gk20a *g,
32 bool prod);
33
34void gp106_slcg_fifo_load_gating_prod(struct gk20a *g,
35 bool prod);
36
37void gr_gp106_slcg_gr_load_gating_prod(struct gk20a *g,
38 bool prod);
39
40void ltc_gp106_slcg_ltc_load_gating_prod(struct gk20a *g,
41 bool prod);
42
43void gp106_slcg_perf_load_gating_prod(struct gk20a *g,
44 bool prod);
45
46void gp106_slcg_priring_load_gating_prod(struct gk20a *g,
47 bool prod);
48
49void gp106_slcg_pmu_load_gating_prod(struct gk20a *g,
50 bool prod);
51
52void gp106_slcg_therm_load_gating_prod(struct gk20a *g,
53 bool prod);
54
55void gp106_slcg_xbar_load_gating_prod(struct gk20a *g,
56 bool prod);
57
58void gp106_blcg_bus_load_gating_prod(struct gk20a *g,
59 bool prod);
60
61void gp106_blcg_ce_load_gating_prod(struct gk20a *g,
62 bool prod);
63
64void gp106_blcg_ctxsw_firmware_load_gating_prod(struct gk20a *g,
65 bool prod);
66
67void gp106_blcg_fb_load_gating_prod(struct gk20a *g,
68 bool prod);
69
70void gp106_blcg_fifo_load_gating_prod(struct gk20a *g,
71 bool prod);
72
73void gp106_blcg_gr_load_gating_prod(struct gk20a *g,
74 bool prod);
75
76void gp106_blcg_ltc_load_gating_prod(struct gk20a *g,
77 bool prod);
78
79void gp106_blcg_pmu_load_gating_prod(struct gk20a *g,
80 bool prod);
81
82void gp106_blcg_xbar_load_gating_prod(struct gk20a *g,
83 bool prod);
84
85void gr_gp106_pg_gr_load_gating_prod(struct gk20a *g,
86 bool prod);
87
diff --git a/drivers/gpu/nvgpu/gp106/gr_ctx_gp106.c b/drivers/gpu/nvgpu/gp106/gr_ctx_gp106.c
new file mode 100644
index 00000000..1f47cc5a
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/gr_ctx_gp106.c
@@ -0,0 +1,50 @@
1/*
2 * GP106 Graphics Context
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include "gk20a/gk20a.h"
17#include "gr_ctx_gp106.h"
18#include "nvgpu_gpuid_t18x.h"
19
20static int gr_gp106_get_netlist_name(struct gk20a *g, int index, char *name)
21{
22 u32 ver = g->gpu_characteristics.arch + g->gpu_characteristics.impl;
23
24 switch (ver) {
25 case NVGPU_GPUID_GP104:
26 sprintf(name, "%s/%s", "gp104",
27 GP104_NETLIST_IMAGE_FW_NAME);
28 break;
29 case NVGPU_GPUID_GP106:
30 sprintf(name, "%s/%s", "gp106",
31 GP106_NETLIST_IMAGE_FW_NAME);
32 break;
33 default:
34 gk20a_err(g->dev, "no support for GPUID %x", ver);
35 }
36
37 return 0;
38}
39
40static bool gr_gp106_is_firmware_defined(void)
41{
42 return true;
43}
44
45void gp106_init_gr_ctx(struct gpu_ops *gops)
46{
47 gops->gr_ctx.get_netlist_name = gr_gp106_get_netlist_name;
48 gops->gr_ctx.is_fw_defined = gr_gp106_is_firmware_defined;
49 gops->gr_ctx.use_dma_for_fw_bootstrap = false;
50}
diff --git a/drivers/gpu/nvgpu/gp106/gr_ctx_gp106.h b/drivers/gpu/nvgpu/gp106/gr_ctx_gp106.h
new file mode 100644
index 00000000..fef80abb
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/gr_ctx_gp106.h
@@ -0,0 +1,27 @@
1/*
2 * Copyright (c) 2016, 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#ifndef __GR_CTX_GP106_H__
17#define __GR_CTX_GP106_H__
18
19#include "gk20a/gr_ctx_gk20a.h"
20
21/* production netlist, one and only one from below */
22#define GP106_NETLIST_IMAGE_FW_NAME GK20A_NETLIST_IMAGE_C
23#define GP104_NETLIST_IMAGE_FW_NAME GK20A_NETLIST_IMAGE_D
24
25void gp106_init_gr_ctx(struct gpu_ops *gops);
26
27#endif /*__GR_CTX_GP106_H__*/
diff --git a/drivers/gpu/nvgpu/gp106/gr_gp106.c b/drivers/gpu/nvgpu/gp106/gr_gp106.c
new file mode 100644
index 00000000..8d8376d3
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/gr_gp106.c
@@ -0,0 +1,239 @@
1/*
2 * GP106 GPU GR
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include "gk20a/gk20a.h" /* FERMI and MAXWELL classes defined here */
17
18#include "gk20a/gr_gk20a.h"
19
20#include "gm20b/gr_gm20b.h" /* for MAXWELL classes */
21#include "gp10b/gr_gp10b.h"
22#include "gr_gp106.h"
23#include "hw_gr_gp106.h"
24
25static bool gr_gp106_is_valid_class(struct gk20a *g, u32 class_num)
26{
27 bool valid = false;
28
29 switch (class_num) {
30 case PASCAL_COMPUTE_A:
31 case PASCAL_COMPUTE_B:
32 case PASCAL_A:
33 case PASCAL_B:
34 case PASCAL_DMA_COPY_A:
35 case PASCAL_DMA_COPY_B:
36 valid = true;
37 break;
38
39 case MAXWELL_COMPUTE_B:
40 case MAXWELL_B:
41 case FERMI_TWOD_A:
42 case KEPLER_DMA_COPY_A:
43 case MAXWELL_DMA_COPY_A:
44 valid = true;
45 break;
46
47 default:
48 break;
49 }
50 gk20a_dbg_info("class=0x%x valid=%d", class_num, valid);
51 return valid;
52}
53
54static u32 gr_gp106_pagepool_default_size(struct gk20a *g)
55{
56 return gr_scc_pagepool_total_pages_hwmax_value_v();
57}
58
59static void gr_gp106_set_go_idle_timeout(struct gk20a *g, u32 data)
60{
61 gk20a_writel(g, gr_fe_go_idle_timeout_r(), data);
62}
63
64static int gr_gp106_handle_sw_method(struct gk20a *g, u32 addr,
65 u32 class_num, u32 offset, u32 data)
66{
67 gk20a_dbg_fn("");
68
69 if (class_num == PASCAL_COMPUTE_B) {
70 switch (offset << 2) {
71 case NVC0C0_SET_SHADER_EXCEPTIONS:
72 gk20a_gr_set_shader_exceptions(g, data);
73 break;
74 default:
75 goto fail;
76 }
77 }
78
79 if (class_num == PASCAL_B) {
80 switch (offset << 2) {
81 case NVC097_SET_SHADER_EXCEPTIONS:
82 gk20a_gr_set_shader_exceptions(g, data);
83 break;
84 case NVC097_SET_CIRCULAR_BUFFER_SIZE:
85 g->ops.gr.set_circular_buffer_size(g, data);
86 break;
87 case NVC097_SET_ALPHA_CIRCULAR_BUFFER_SIZE:
88 g->ops.gr.set_alpha_circular_buffer_size(g, data);
89 break;
90 case NVC097_SET_GO_IDLE_TIMEOUT:
91 gr_gp106_set_go_idle_timeout(g, data);
92 break;
93 default:
94 goto fail;
95 }
96 }
97 return 0;
98
99fail:
100 return -EINVAL;
101}
102
103static void gr_gp106_cb_size_default(struct gk20a *g)
104{
105 struct gr_gk20a *gr = &g->gr;
106
107 if (!gr->attrib_cb_default_size)
108 gr->attrib_cb_default_size = 0x800;
109 gr->alpha_cb_default_size =
110 gr_gpc0_ppc0_cbm_alpha_cb_size_v_default_v();
111}
112
113static int gr_gp106_set_ctxsw_preemption_mode(struct gk20a *g,
114 struct gr_ctx_desc *gr_ctx,
115 struct vm_gk20a *vm, u32 class,
116 u32 graphics_preempt_mode,
117 u32 compute_preempt_mode)
118{
119 int err = 0;
120
121 if (class == PASCAL_B && g->gr.t18x.ctx_vars.force_preemption_gfxp)
122 graphics_preempt_mode = NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP;
123
124 if (class == PASCAL_COMPUTE_B &&
125 g->gr.t18x.ctx_vars.force_preemption_cilp)
126 compute_preempt_mode = NVGPU_COMPUTE_PREEMPTION_MODE_CILP;
127
128 /* check for invalid combinations */
129 if ((graphics_preempt_mode == 0) && (compute_preempt_mode == 0))
130 return -EINVAL;
131
132 if ((graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) &&
133 (compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP))
134 return -EINVAL;
135
136 /* set preemption modes */
137 switch (graphics_preempt_mode) {
138 case NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP:
139 {
140 u32 spill_size =
141 gr_gpc0_swdx_rm_spill_buffer_size_256b_default_v() *
142 gr_gpc0_swdx_rm_spill_buffer_size_256b_byte_granularity_v();
143 u32 pagepool_size = g->ops.gr.pagepool_default_size(g) *
144 gr_scc_pagepool_total_pages_byte_granularity_v();
145 u32 betacb_size = g->gr.attrib_cb_default_size +
146 (gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v() -
147 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v());
148 u32 attrib_cb_size = (betacb_size + g->gr.alpha_cb_size) *
149 gr_gpc0_ppc0_cbm_beta_cb_size_v_granularity_v() *
150 g->gr.max_tpc_count;
151 attrib_cb_size = ALIGN(attrib_cb_size, 128);
152
153 gk20a_dbg_info("gfxp context spill_size=%d", spill_size);
154 gk20a_dbg_info("gfxp context pagepool_size=%d", pagepool_size);
155 gk20a_dbg_info("gfxp context attrib_cb_size=%d",
156 attrib_cb_size);
157
158 err = gr_gp10b_alloc_buffer(vm,
159 g->gr.t18x.ctx_vars.preempt_image_size,
160 &gr_ctx->t18x.preempt_ctxsw_buffer);
161 if (err) {
162 gk20a_err(dev_from_gk20a(g),
163 "cannot allocate preempt buffer");
164 goto fail;
165 }
166
167 err = gr_gp10b_alloc_buffer(vm,
168 spill_size,
169 &gr_ctx->t18x.spill_ctxsw_buffer);
170 if (err) {
171 gk20a_err(dev_from_gk20a(g),
172 "cannot allocate spill buffer");
173 goto fail_free_preempt;
174 }
175
176 err = gr_gp10b_alloc_buffer(vm,
177 attrib_cb_size,
178 &gr_ctx->t18x.betacb_ctxsw_buffer);
179 if (err) {
180 gk20a_err(dev_from_gk20a(g),
181 "cannot allocate beta buffer");
182 goto fail_free_spill;
183 }
184
185 err = gr_gp10b_alloc_buffer(vm,
186 pagepool_size,
187 &gr_ctx->t18x.pagepool_ctxsw_buffer);
188 if (err) {
189 gk20a_err(dev_from_gk20a(g),
190 "cannot allocate page pool");
191 goto fail_free_betacb;
192 }
193
194 gr_ctx->graphics_preempt_mode = graphics_preempt_mode;
195 break;
196 }
197
198 case NVGPU_GRAPHICS_PREEMPTION_MODE_WFI:
199 gr_ctx->graphics_preempt_mode = graphics_preempt_mode;
200 break;
201
202 default:
203 break;
204 }
205
206 if (class == PASCAL_COMPUTE_B) {
207 switch (compute_preempt_mode) {
208 case NVGPU_COMPUTE_PREEMPTION_MODE_WFI:
209 case NVGPU_COMPUTE_PREEMPTION_MODE_CTA:
210 case NVGPU_COMPUTE_PREEMPTION_MODE_CILP:
211 gr_ctx->compute_preempt_mode = compute_preempt_mode;
212 break;
213 default:
214 break;
215 }
216 }
217
218 return 0;
219
220fail_free_betacb:
221 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.betacb_ctxsw_buffer);
222fail_free_spill:
223 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.spill_ctxsw_buffer);
224fail_free_preempt:
225 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.preempt_ctxsw_buffer);
226fail:
227 return err;
228}
229
230void gp106_init_gr(struct gpu_ops *gops)
231{
232 gp10b_init_gr(gops);
233 gops->gr.is_valid_class = gr_gp106_is_valid_class;
234 gops->gr.pagepool_default_size = gr_gp106_pagepool_default_size;
235 gops->gr.handle_sw_method = gr_gp106_handle_sw_method;
236 gops->gr.cb_size_default = gr_gp106_cb_size_default;
237 gops->gr.init_preemption_state = NULL;
238 gops->gr.set_ctxsw_preemption_mode = gr_gp106_set_ctxsw_preemption_mode;
239}
diff --git a/drivers/gpu/nvgpu/gp106/gr_gp106.h b/drivers/gpu/nvgpu/gp106/gr_gp106.h
new file mode 100644
index 00000000..4fe22ee9
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/gr_gp106.h
@@ -0,0 +1,26 @@
1/*
2 * GP106 GPU GR
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _NVGPU_GR_GP106_H_
17#define _NVGPU_GR_GP106_H_
18
19enum {
20 PASCAL_B = 0xC197,
21 PASCAL_COMPUTE_B = 0xC1C0,
22};
23
24void gp106_init_gr(struct gpu_ops *gops);
25
26#endif
diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c
new file mode 100644
index 00000000..ee361953
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c
@@ -0,0 +1,259 @@
1/*
2 * GP106 HAL interface
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/types.h>
17#include <linux/printk.h>
18
19#include <linux/types.h>
20
21#include "gk20a/gk20a.h"
22
23#include "gp10b/gr_gp10b.h"
24#include "gp10b/mc_gp10b.h"
25#include "gp106/ltc_gp106.h"
26#include "gp10b/mm_gp10b.h"
27#include "gp10b/ce_gp10b.h"
28#include "gp106/fifo_gp106.h"
29#include "gp106/regops_gp106.h"
30#include "gp10b/cde_gp10b.h"
31#include "gp106/therm_gp106.h"
32#include "gp106/xve_gp106.h"
33
34#include "gp106/bios_gp106.h"
35
36#include "gm20b/gr_gm20b.h"
37#include "gm20b/fifo_gm20b.h"
38#include "gm20b/pmu_gm20b.h"
39#include "gp106/clk_gp106.h"
40#include "gp106/clk_arb_gp106.h"
41
42#include "gp106/mm_gp106.h"
43#include "gp106/pmu_gp106.h"
44#include "gp106/gr_ctx_gp106.h"
45#include "gp106/gr_gp106.h"
46#include "gp106/fb_gp106.h"
47#include "gp106/gp106_gating_reglist.h"
48#include "nvgpu_gpuid_t18x.h"
49#include "hw_proj_gp106.h"
50#include "gk20a/dbg_gpu_gk20a.h"
51#include "gk20a/css_gr_gk20a.h"
52
53static struct gpu_ops gp106_ops = {
54 .clock_gating = {
55 .slcg_bus_load_gating_prod =
56 gp106_slcg_bus_load_gating_prod,
57 .slcg_ce2_load_gating_prod =
58 gp106_slcg_ce2_load_gating_prod,
59 .slcg_chiplet_load_gating_prod =
60 gp106_slcg_chiplet_load_gating_prod,
61 .slcg_ctxsw_firmware_load_gating_prod =
62 gp106_slcg_ctxsw_firmware_load_gating_prod,
63 .slcg_fb_load_gating_prod =
64 gp106_slcg_fb_load_gating_prod,
65 .slcg_fifo_load_gating_prod =
66 gp106_slcg_fifo_load_gating_prod,
67 .slcg_gr_load_gating_prod =
68 gr_gp106_slcg_gr_load_gating_prod,
69 .slcg_ltc_load_gating_prod =
70 ltc_gp106_slcg_ltc_load_gating_prod,
71 .slcg_perf_load_gating_prod =
72 gp106_slcg_perf_load_gating_prod,
73 .slcg_priring_load_gating_prod =
74 gp106_slcg_priring_load_gating_prod,
75 .slcg_pmu_load_gating_prod =
76 gp106_slcg_pmu_load_gating_prod,
77 .slcg_therm_load_gating_prod =
78 gp106_slcg_therm_load_gating_prod,
79 .slcg_xbar_load_gating_prod =
80 gp106_slcg_xbar_load_gating_prod,
81 .blcg_bus_load_gating_prod =
82 gp106_blcg_bus_load_gating_prod,
83 .blcg_ce_load_gating_prod =
84 gp106_blcg_ce_load_gating_prod,
85 .blcg_fb_load_gating_prod =
86 gp106_blcg_fb_load_gating_prod,
87 .blcg_fifo_load_gating_prod =
88 gp106_blcg_fifo_load_gating_prod,
89 .blcg_gr_load_gating_prod =
90 gp106_blcg_gr_load_gating_prod,
91 .blcg_ltc_load_gating_prod =
92 gp106_blcg_ltc_load_gating_prod,
93 .blcg_pmu_load_gating_prod =
94 gp106_blcg_pmu_load_gating_prod,
95 .blcg_xbar_load_gating_prod =
96 gp106_blcg_xbar_load_gating_prod,
97 .pg_gr_load_gating_prod =
98 gr_gp106_pg_gr_load_gating_prod,
99 }
100};
101
102static int gp106_get_litter_value(struct gk20a *g, int value)
103{
104 int ret = -EINVAL;
105
106 switch (value) {
107 case GPU_LIT_NUM_GPCS:
108 ret = proj_scal_litter_num_gpcs_v();
109 break;
110 case GPU_LIT_NUM_PES_PER_GPC:
111 ret = proj_scal_litter_num_pes_per_gpc_v();
112 break;
113 case GPU_LIT_NUM_ZCULL_BANKS:
114 ret = proj_scal_litter_num_zcull_banks_v();
115 break;
116 case GPU_LIT_NUM_TPC_PER_GPC:
117 ret = proj_scal_litter_num_tpc_per_gpc_v();
118 break;
119 case GPU_LIT_NUM_FBPS:
120 ret = proj_scal_litter_num_fbps_v();
121 break;
122 case GPU_LIT_GPC_BASE:
123 ret = proj_gpc_base_v();
124 break;
125 case GPU_LIT_GPC_STRIDE:
126 ret = proj_gpc_stride_v();
127 break;
128 case GPU_LIT_GPC_SHARED_BASE:
129 ret = proj_gpc_shared_base_v();
130 break;
131 case GPU_LIT_TPC_IN_GPC_BASE:
132 ret = proj_tpc_in_gpc_base_v();
133 break;
134 case GPU_LIT_TPC_IN_GPC_STRIDE:
135 ret = proj_tpc_in_gpc_stride_v();
136 break;
137 case GPU_LIT_TPC_IN_GPC_SHARED_BASE:
138 ret = proj_tpc_in_gpc_shared_base_v();
139 break;
140 case GPU_LIT_PPC_IN_GPC_BASE:
141 ret = proj_ppc_in_gpc_base_v();
142 break;
143 case GPU_LIT_PPC_IN_GPC_STRIDE:
144 ret = proj_ppc_in_gpc_stride_v();
145 break;
146 case GPU_LIT_PPC_IN_GPC_SHARED_BASE:
147 ret = proj_ppc_in_gpc_shared_base_v();
148 break;
149 case GPU_LIT_ROP_BASE:
150 ret = proj_rop_base_v();
151 break;
152 case GPU_LIT_ROP_STRIDE:
153 ret = proj_rop_stride_v();
154 break;
155 case GPU_LIT_ROP_SHARED_BASE:
156 ret = proj_rop_shared_base_v();
157 break;
158 case GPU_LIT_HOST_NUM_ENGINES:
159 ret = proj_host_num_engines_v();
160 break;
161 case GPU_LIT_HOST_NUM_PBDMA:
162 ret = proj_host_num_pbdma_v();
163 break;
164 case GPU_LIT_LTC_STRIDE:
165 ret = proj_ltc_stride_v();
166 break;
167 case GPU_LIT_LTS_STRIDE:
168 ret = proj_lts_stride_v();
169 break;
170 case GPU_LIT_NUM_FBPAS:
171 ret = proj_scal_litter_num_fbpas_v();
172 break;
173 case GPU_LIT_FBPA_SHARED_BASE:
174 ret = proj_fbpa_shared_base_v();
175 break;
176 case GPU_LIT_FBPA_BASE:
177 ret = proj_fbpa_base_v();
178 break;
179 case GPU_LIT_FBPA_STRIDE:
180 ret = proj_fbpa_stride_v();
181 break;
182 default:
183 BUG();
184 break;
185 }
186
187 return ret;
188}
189
190int gp106_init_gpu_characteristics(struct gk20a *g)
191{
192 struct nvgpu_gpu_characteristics *gpu = &g->gpu_characteristics;
193
194 int err;
195
196 err = gk20a_init_gpu_characteristics(g);
197 if (err)
198 return err;
199
200 gpu->flags |= NVGPU_GPU_FLAGS_SUPPORT_GET_VOLTAGE |
201 NVGPU_GPU_FLAGS_SUPPORT_GET_CURRENT |
202 NVGPU_GPU_FLAGS_SUPPORT_GET_POWER |
203 NVGPU_GPU_FLAGS_SUPPORT_GET_TEMPERATURE;
204
205 return 0;
206}
207
208int gp106_init_hal(struct gk20a *g)
209{
210 struct gpu_ops *gops = &g->ops;
211 struct nvgpu_gpu_characteristics *c = &g->gpu_characteristics;
212
213 gk20a_dbg_fn("");
214
215 *gops = gp106_ops;
216
217 gops->privsecurity = 1;
218 gops->securegpccs = 1;
219 gops->pmupstate = true;
220 gp10b_init_mc(gops);
221 gp106_init_gr(gops);
222 gp106_init_ltc(gops);
223 gp106_init_fb(gops);
224 gp106_init_fifo(gops);
225 gp10b_init_ce(gops);
226 gp106_init_gr_ctx(gops);
227 gp106_init_mm(gops);
228 gp106_init_pmu_ops(gops);
229 gk20a_init_debug_ops(gops);
230 gk20a_init_dbg_session_ops(gops);
231 gp106_init_clk_ops(gops);
232 gp106_init_clk_arb_ops(gops);
233 gp106_init_regops(gops);
234 gp10b_init_cde_ops(gops);
235 gk20a_init_tsg_ops(gops);
236#if defined(CONFIG_GK20A_CYCLE_STATS)
237 gk20a_init_css_ops(gops);
238#endif
239 gp106_init_bios(gops);
240 gp106_init_therm_ops(gops);
241 gp106_init_xve_ops(gops);
242
243 gops->name = "gp10x";
244 gops->get_litter_value = gp106_get_litter_value;
245 gops->chip_init_gpu_characteristics = gp106_init_gpu_characteristics;
246 gops->gr_ctx.use_dma_for_fw_bootstrap = true;
247 gops->read_ptimer = gk20a_read_ptimer;
248
249 c->twod_class = FERMI_TWOD_A;
250 c->threed_class = PASCAL_B;
251 c->compute_class = PASCAL_COMPUTE_B;
252 c->gpfifo_class = PASCAL_CHANNEL_GPFIFO_A;
253 c->inline_to_memory_class = KEPLER_INLINE_TO_MEMORY_B;
254 c->dma_copy_class = PASCAL_DMA_COPY_A;
255
256 gk20a_dbg_fn("done");
257
258 return 0;
259}
diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.h b/drivers/gpu/nvgpu/gp106/hal_gp106.h
new file mode 100644
index 00000000..af91267b
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hal_gp106.h
@@ -0,0 +1,21 @@
1/*
2 * GP106 Tegra HAL interface
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _NVGPU_HAL_GP106_H
17#define _NVGPU_HAL_GP106_H
18struct gk20a;
19
20int gp106_init_hal(struct gk20a *gops);
21#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_bus_gp106.h b/drivers/gpu/nvgpu/gp106/hw_bus_gp106.h
new file mode 100644
index 00000000..6d80b6a6
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_bus_gp106.h
@@ -0,0 +1,193 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_bus_gp106_h_
51#define _hw_bus_gp106_h_
52
53static inline u32 bus_bar1_block_r(void)
54{
55 return 0x00001704;
56}
57static inline u32 bus_bar1_block_ptr_f(u32 v)
58{
59 return (v & 0xfffffff) << 0;
60}
61static inline u32 bus_bar1_block_target_vid_mem_f(void)
62{
63 return 0x0;
64}
65static inline u32 bus_bar1_block_target_sys_mem_coh_f(void)
66{
67 return 0x20000000;
68}
69static inline u32 bus_bar1_block_target_sys_mem_ncoh_f(void)
70{
71 return 0x30000000;
72}
73static inline u32 bus_bar1_block_mode_virtual_f(void)
74{
75 return 0x80000000;
76}
77static inline u32 bus_bar2_block_r(void)
78{
79 return 0x00001714;
80}
81static inline u32 bus_bar2_block_ptr_f(u32 v)
82{
83 return (v & 0xfffffff) << 0;
84}
85static inline u32 bus_bar2_block_target_vid_mem_f(void)
86{
87 return 0x0;
88}
89static inline u32 bus_bar2_block_target_sys_mem_coh_f(void)
90{
91 return 0x20000000;
92}
93static inline u32 bus_bar2_block_target_sys_mem_ncoh_f(void)
94{
95 return 0x30000000;
96}
97static inline u32 bus_bar2_block_mode_virtual_f(void)
98{
99 return 0x80000000;
100}
101static inline u32 bus_bar1_block_ptr_shift_v(void)
102{
103 return 0x0000000c;
104}
105static inline u32 bus_bar2_block_ptr_shift_v(void)
106{
107 return 0x0000000c;
108}
109static inline u32 bus_bind_status_r(void)
110{
111 return 0x00001710;
112}
113static inline u32 bus_bind_status_bar1_pending_v(u32 r)
114{
115 return (r >> 0) & 0x1;
116}
117static inline u32 bus_bind_status_bar1_pending_empty_f(void)
118{
119 return 0x0;
120}
121static inline u32 bus_bind_status_bar1_pending_busy_f(void)
122{
123 return 0x1;
124}
125static inline u32 bus_bind_status_bar1_outstanding_v(u32 r)
126{
127 return (r >> 1) & 0x1;
128}
129static inline u32 bus_bind_status_bar1_outstanding_false_f(void)
130{
131 return 0x0;
132}
133static inline u32 bus_bind_status_bar1_outstanding_true_f(void)
134{
135 return 0x2;
136}
137static inline u32 bus_bind_status_bar2_pending_v(u32 r)
138{
139 return (r >> 2) & 0x1;
140}
141static inline u32 bus_bind_status_bar2_pending_empty_f(void)
142{
143 return 0x0;
144}
145static inline u32 bus_bind_status_bar2_pending_busy_f(void)
146{
147 return 0x4;
148}
149static inline u32 bus_bind_status_bar2_outstanding_v(u32 r)
150{
151 return (r >> 3) & 0x1;
152}
153static inline u32 bus_bind_status_bar2_outstanding_false_f(void)
154{
155 return 0x0;
156}
157static inline u32 bus_bind_status_bar2_outstanding_true_f(void)
158{
159 return 0x8;
160}
161static inline u32 bus_intr_0_r(void)
162{
163 return 0x00001100;
164}
165static inline u32 bus_intr_0_pri_squash_m(void)
166{
167 return 0x1 << 1;
168}
169static inline u32 bus_intr_0_pri_fecserr_m(void)
170{
171 return 0x1 << 2;
172}
173static inline u32 bus_intr_0_pri_timeout_m(void)
174{
175 return 0x1 << 3;
176}
177static inline u32 bus_intr_en_0_r(void)
178{
179 return 0x00001140;
180}
181static inline u32 bus_intr_en_0_pri_squash_m(void)
182{
183 return 0x1 << 1;
184}
185static inline u32 bus_intr_en_0_pri_fecserr_m(void)
186{
187 return 0x1 << 2;
188}
189static inline u32 bus_intr_en_0_pri_timeout_m(void)
190{
191 return 0x1 << 3;
192}
193#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_ccsr_gp106.h b/drivers/gpu/nvgpu/gp106/hw_ccsr_gp106.h
new file mode 100644
index 00000000..65146d39
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_ccsr_gp106.h
@@ -0,0 +1,125 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ccsr_gp106_h_
51#define _hw_ccsr_gp106_h_
52
53static inline u32 ccsr_channel_inst_r(u32 i)
54{
55 return 0x00800000 + i*8;
56}
57static inline u32 ccsr_channel_inst__size_1_v(void)
58{
59 return 0x00001000;
60}
61static inline u32 ccsr_channel_inst_ptr_f(u32 v)
62{
63 return (v & 0xfffffff) << 0;
64}
65static inline u32 ccsr_channel_inst_target_vid_mem_f(void)
66{
67 return 0x0;
68}
69static inline u32 ccsr_channel_inst_target_sys_mem_coh_f(void)
70{
71 return 0x20000000;
72}
73static inline u32 ccsr_channel_inst_target_sys_mem_ncoh_f(void)
74{
75 return 0x30000000;
76}
77static inline u32 ccsr_channel_inst_bind_false_f(void)
78{
79 return 0x0;
80}
81static inline u32 ccsr_channel_inst_bind_true_f(void)
82{
83 return 0x80000000;
84}
85static inline u32 ccsr_channel_r(u32 i)
86{
87 return 0x00800004 + i*8;
88}
89static inline u32 ccsr_channel__size_1_v(void)
90{
91 return 0x00001000;
92}
93static inline u32 ccsr_channel_enable_v(u32 r)
94{
95 return (r >> 0) & 0x1;
96}
97static inline u32 ccsr_channel_enable_set_f(u32 v)
98{
99 return (v & 0x1) << 10;
100}
101static inline u32 ccsr_channel_enable_set_true_f(void)
102{
103 return 0x400;
104}
105static inline u32 ccsr_channel_enable_clr_true_f(void)
106{
107 return 0x800;
108}
109static inline u32 ccsr_channel_status_v(u32 r)
110{
111 return (r >> 24) & 0xf;
112}
113static inline u32 ccsr_channel_status_pending_ctx_reload_v(void)
114{
115 return 0x00000002;
116}
117static inline u32 ccsr_channel_busy_v(u32 r)
118{
119 return (r >> 28) & 0x1;
120}
121static inline u32 ccsr_channel_next_v(u32 r)
122{
123 return (r >> 1) & 0x1;
124}
125#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_ce_gp106.h b/drivers/gpu/nvgpu/gp106/hw_ce_gp106.h
new file mode 100644
index 00000000..36311136
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_ce_gp106.h
@@ -0,0 +1,81 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ce_gp106_h_
51#define _hw_ce_gp106_h_
52
53static inline u32 ce_intr_status_r(u32 i)
54{
55 return 0x00104410 + i*128;
56}
57static inline u32 ce_intr_status_blockpipe_pending_f(void)
58{
59 return 0x1;
60}
61static inline u32 ce_intr_status_blockpipe_reset_f(void)
62{
63 return 0x1;
64}
65static inline u32 ce_intr_status_nonblockpipe_pending_f(void)
66{
67 return 0x2;
68}
69static inline u32 ce_intr_status_nonblockpipe_reset_f(void)
70{
71 return 0x2;
72}
73static inline u32 ce_intr_status_launcherr_pending_f(void)
74{
75 return 0x4;
76}
77static inline u32 ce_intr_status_launcherr_reset_f(void)
78{
79 return 0x4;
80}
81#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_ctxsw_prog_gp106.h b/drivers/gpu/nvgpu/gp106/hw_ctxsw_prog_gp106.h
new file mode 100644
index 00000000..ed3e6009
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_ctxsw_prog_gp106.h
@@ -0,0 +1,289 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ctxsw_prog_gp106_h_
51#define _hw_ctxsw_prog_gp106_h_
52
53static inline u32 ctxsw_prog_fecs_header_v(void)
54{
55 return 0x00000100;
56}
57static inline u32 ctxsw_prog_main_image_num_gpcs_o(void)
58{
59 return 0x00000008;
60}
61static inline u32 ctxsw_prog_main_image_patch_count_o(void)
62{
63 return 0x00000010;
64}
65static inline u32 ctxsw_prog_main_image_patch_adr_lo_o(void)
66{
67 return 0x00000014;
68}
69static inline u32 ctxsw_prog_main_image_patch_adr_hi_o(void)
70{
71 return 0x00000018;
72}
73static inline u32 ctxsw_prog_main_image_zcull_o(void)
74{
75 return 0x0000001c;
76}
77static inline u32 ctxsw_prog_main_image_zcull_mode_no_ctxsw_v(void)
78{
79 return 0x00000001;
80}
81static inline u32 ctxsw_prog_main_image_zcull_mode_separate_buffer_v(void)
82{
83 return 0x00000002;
84}
85static inline u32 ctxsw_prog_main_image_zcull_ptr_o(void)
86{
87 return 0x00000020;
88}
89static inline u32 ctxsw_prog_main_image_pm_o(void)
90{
91 return 0x00000028;
92}
93static inline u32 ctxsw_prog_main_image_pm_mode_m(void)
94{
95 return 0x7 << 0;
96}
97static inline u32 ctxsw_prog_main_image_pm_mode_no_ctxsw_f(void)
98{
99 return 0x0;
100}
101static inline u32 ctxsw_prog_main_image_pm_smpc_mode_m(void)
102{
103 return 0x7 << 3;
104}
105static inline u32 ctxsw_prog_main_image_pm_smpc_mode_ctxsw_f(void)
106{
107 return 0x8;
108}
109static inline u32 ctxsw_prog_main_image_pm_smpc_mode_no_ctxsw_f(void)
110{
111 return 0x0;
112}
113static inline u32 ctxsw_prog_main_image_pm_ptr_o(void)
114{
115 return 0x0000002c;
116}
117static inline u32 ctxsw_prog_main_image_num_save_ops_o(void)
118{
119 return 0x000000f4;
120}
121static inline u32 ctxsw_prog_main_image_num_wfi_save_ops_o(void)
122{
123 return 0x000000d0;
124}
125static inline u32 ctxsw_prog_main_image_num_cta_save_ops_o(void)
126{
127 return 0x000000d4;
128}
129static inline u32 ctxsw_prog_main_image_num_gfxp_save_ops_o(void)
130{
131 return 0x000000d8;
132}
133static inline u32 ctxsw_prog_main_image_num_cilp_save_ops_o(void)
134{
135 return 0x000000dc;
136}
137static inline u32 ctxsw_prog_main_image_num_restore_ops_o(void)
138{
139 return 0x000000f8;
140}
141static inline u32 ctxsw_prog_main_image_magic_value_o(void)
142{
143 return 0x000000fc;
144}
145static inline u32 ctxsw_prog_main_image_magic_value_v_value_v(void)
146{
147 return 0x600dc0de;
148}
149static inline u32 ctxsw_prog_local_priv_register_ctl_o(void)
150{
151 return 0x0000000c;
152}
153static inline u32 ctxsw_prog_local_priv_register_ctl_offset_v(u32 r)
154{
155 return (r >> 0) & 0xffff;
156}
157static inline u32 ctxsw_prog_local_image_ppc_info_o(void)
158{
159 return 0x000000f4;
160}
161static inline u32 ctxsw_prog_local_image_ppc_info_num_ppcs_v(u32 r)
162{
163 return (r >> 0) & 0xffff;
164}
165static inline u32 ctxsw_prog_local_image_ppc_info_ppc_mask_v(u32 r)
166{
167 return (r >> 16) & 0xffff;
168}
169static inline u32 ctxsw_prog_local_image_num_tpcs_o(void)
170{
171 return 0x000000f8;
172}
173static inline u32 ctxsw_prog_local_magic_value_o(void)
174{
175 return 0x000000fc;
176}
177static inline u32 ctxsw_prog_local_magic_value_v_value_v(void)
178{
179 return 0xad0becab;
180}
181static inline u32 ctxsw_prog_main_extended_buffer_ctl_o(void)
182{
183 return 0x000000ec;
184}
185static inline u32 ctxsw_prog_main_extended_buffer_ctl_offset_v(u32 r)
186{
187 return (r >> 0) & 0xffff;
188}
189static inline u32 ctxsw_prog_main_extended_buffer_ctl_size_v(u32 r)
190{
191 return (r >> 16) & 0xff;
192}
193static inline u32 ctxsw_prog_extended_buffer_segments_size_in_bytes_v(void)
194{
195 return 0x00000100;
196}
197static inline u32 ctxsw_prog_extended_marker_size_in_bytes_v(void)
198{
199 return 0x00000004;
200}
201static inline u32 ctxsw_prog_extended_sm_dsm_perf_counter_register_stride_v(void)
202{
203 return 0x00000000;
204}
205static inline u32 ctxsw_prog_extended_sm_dsm_perf_counter_control_register_stride_v(void)
206{
207 return 0x00000002;
208}
209static inline u32 ctxsw_prog_main_image_priv_access_map_config_o(void)
210{
211 return 0x000000a0;
212}
213static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_s(void)
214{
215 return 2;
216}
217static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_f(u32 v)
218{
219 return (v & 0x3) << 0;
220}
221static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_m(void)
222{
223 return 0x3 << 0;
224}
225static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_v(u32 r)
226{
227 return (r >> 0) & 0x3;
228}
229static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_allow_all_f(void)
230{
231 return 0x0;
232}
233static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_use_map_f(void)
234{
235 return 0x2;
236}
237static inline u32 ctxsw_prog_main_image_priv_access_map_addr_lo_o(void)
238{
239 return 0x000000a4;
240}
241static inline u32 ctxsw_prog_main_image_priv_access_map_addr_hi_o(void)
242{
243 return 0x000000a8;
244}
245static inline u32 ctxsw_prog_main_image_misc_options_o(void)
246{
247 return 0x0000003c;
248}
249static inline u32 ctxsw_prog_main_image_misc_options_verif_features_m(void)
250{
251 return 0x1 << 3;
252}
253static inline u32 ctxsw_prog_main_image_misc_options_verif_features_disabled_f(void)
254{
255 return 0x0;
256}
257static inline u32 ctxsw_prog_main_image_graphics_preemption_options_o(void)
258{
259 return 0x00000080;
260}
261static inline u32 ctxsw_prog_main_image_graphics_preemption_options_control_f(u32 v)
262{
263 return (v & 0x3) << 0;
264}
265static inline u32 ctxsw_prog_main_image_graphics_preemption_options_control_gfxp_f(void)
266{
267 return 0x1;
268}
269static inline u32 ctxsw_prog_main_image_full_preemption_ptr_o(void)
270{
271 return 0x00000068;
272}
273static inline u32 ctxsw_prog_main_image_compute_preemption_options_o(void)
274{
275 return 0x00000084;
276}
277static inline u32 ctxsw_prog_main_image_compute_preemption_options_control_f(u32 v)
278{
279 return (v & 0x3) << 0;
280}
281static inline u32 ctxsw_prog_main_image_compute_preemption_options_control_cta_f(void)
282{
283 return 0x1;
284}
285static inline u32 ctxsw_prog_main_image_compute_preemption_options_control_cilp_f(void)
286{
287 return 0x2;
288}
289#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_fb_gp106.h b/drivers/gpu/nvgpu/gp106/hw_fb_gp106.h
new file mode 100644
index 00000000..519679f5
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_fb_gp106.h
@@ -0,0 +1,609 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_fb_gp106_h_
51#define _hw_fb_gp106_h_
52
53static inline u32 fb_fbhub_num_active_ltcs_r(void)
54{
55 return 0x00100800;
56}
57static inline u32 fb_mmu_ctrl_r(void)
58{
59 return 0x00100c80;
60}
61static inline u32 fb_mmu_ctrl_vm_pg_size_f(u32 v)
62{
63 return (v & 0x1) << 0;
64}
65static inline u32 fb_mmu_ctrl_vm_pg_size_128kb_f(void)
66{
67 return 0x0;
68}
69static inline u32 fb_mmu_ctrl_vm_pg_size_64kb_f(void)
70{
71 return 0x1;
72}
73static inline u32 fb_mmu_ctrl_pri_fifo_empty_v(u32 r)
74{
75 return (r >> 15) & 0x1;
76}
77static inline u32 fb_mmu_ctrl_pri_fifo_empty_false_f(void)
78{
79 return 0x0;
80}
81static inline u32 fb_mmu_ctrl_pri_fifo_space_v(u32 r)
82{
83 return (r >> 16) & 0xff;
84}
85static inline u32 fb_mmu_ctrl_use_pdb_big_page_size_v(u32 r)
86{
87 return (r >> 11) & 0x1;
88}
89static inline u32 fb_mmu_ctrl_use_pdb_big_page_size_true_f(void)
90{
91 return 0x800;
92}
93static inline u32 fb_mmu_ctrl_use_pdb_big_page_size_false_f(void)
94{
95 return 0x0;
96}
97static inline u32 fb_priv_mmu_phy_secure_r(void)
98{
99 return 0x00100ce4;
100}
101static inline u32 fb_mmu_invalidate_pdb_r(void)
102{
103 return 0x00100cb8;
104}
105static inline u32 fb_mmu_invalidate_pdb_aperture_vid_mem_f(void)
106{
107 return 0x0;
108}
109static inline u32 fb_mmu_invalidate_pdb_aperture_sys_mem_f(void)
110{
111 return 0x2;
112}
113static inline u32 fb_mmu_invalidate_pdb_addr_f(u32 v)
114{
115 return (v & 0xfffffff) << 4;
116}
117static inline u32 fb_mmu_invalidate_r(void)
118{
119 return 0x00100cbc;
120}
121static inline u32 fb_mmu_invalidate_all_va_true_f(void)
122{
123 return 0x1;
124}
125static inline u32 fb_mmu_invalidate_all_pdb_true_f(void)
126{
127 return 0x2;
128}
129static inline u32 fb_mmu_invalidate_hubtlb_only_s(void)
130{
131 return 1;
132}
133static inline u32 fb_mmu_invalidate_hubtlb_only_f(u32 v)
134{
135 return (v & 0x1) << 2;
136}
137static inline u32 fb_mmu_invalidate_hubtlb_only_m(void)
138{
139 return 0x1 << 2;
140}
141static inline u32 fb_mmu_invalidate_hubtlb_only_v(u32 r)
142{
143 return (r >> 2) & 0x1;
144}
145static inline u32 fb_mmu_invalidate_hubtlb_only_true_f(void)
146{
147 return 0x4;
148}
149static inline u32 fb_mmu_invalidate_replay_s(void)
150{
151 return 3;
152}
153static inline u32 fb_mmu_invalidate_replay_f(u32 v)
154{
155 return (v & 0x7) << 3;
156}
157static inline u32 fb_mmu_invalidate_replay_m(void)
158{
159 return 0x7 << 3;
160}
161static inline u32 fb_mmu_invalidate_replay_v(u32 r)
162{
163 return (r >> 3) & 0x7;
164}
165static inline u32 fb_mmu_invalidate_replay_none_f(void)
166{
167 return 0x0;
168}
169static inline u32 fb_mmu_invalidate_replay_start_f(void)
170{
171 return 0x8;
172}
173static inline u32 fb_mmu_invalidate_replay_start_ack_all_f(void)
174{
175 return 0x10;
176}
177static inline u32 fb_mmu_invalidate_replay_cancel_targeted_f(void)
178{
179 return 0x18;
180}
181static inline u32 fb_mmu_invalidate_replay_cancel_global_f(void)
182{
183 return 0x20;
184}
185static inline u32 fb_mmu_invalidate_replay_cancel_f(void)
186{
187 return 0x20;
188}
189static inline u32 fb_mmu_invalidate_sys_membar_s(void)
190{
191 return 1;
192}
193static inline u32 fb_mmu_invalidate_sys_membar_f(u32 v)
194{
195 return (v & 0x1) << 6;
196}
197static inline u32 fb_mmu_invalidate_sys_membar_m(void)
198{
199 return 0x1 << 6;
200}
201static inline u32 fb_mmu_invalidate_sys_membar_v(u32 r)
202{
203 return (r >> 6) & 0x1;
204}
205static inline u32 fb_mmu_invalidate_sys_membar_true_f(void)
206{
207 return 0x40;
208}
209static inline u32 fb_mmu_invalidate_ack_s(void)
210{
211 return 2;
212}
213static inline u32 fb_mmu_invalidate_ack_f(u32 v)
214{
215 return (v & 0x3) << 7;
216}
217static inline u32 fb_mmu_invalidate_ack_m(void)
218{
219 return 0x3 << 7;
220}
221static inline u32 fb_mmu_invalidate_ack_v(u32 r)
222{
223 return (r >> 7) & 0x3;
224}
225static inline u32 fb_mmu_invalidate_ack_ack_none_required_f(void)
226{
227 return 0x0;
228}
229static inline u32 fb_mmu_invalidate_ack_ack_intranode_f(void)
230{
231 return 0x100;
232}
233static inline u32 fb_mmu_invalidate_ack_ack_globally_f(void)
234{
235 return 0x80;
236}
237static inline u32 fb_mmu_invalidate_cancel_client_id_s(void)
238{
239 return 6;
240}
241static inline u32 fb_mmu_invalidate_cancel_client_id_f(u32 v)
242{
243 return (v & 0x3f) << 9;
244}
245static inline u32 fb_mmu_invalidate_cancel_client_id_m(void)
246{
247 return 0x3f << 9;
248}
249static inline u32 fb_mmu_invalidate_cancel_client_id_v(u32 r)
250{
251 return (r >> 9) & 0x3f;
252}
253static inline u32 fb_mmu_invalidate_cancel_gpc_id_s(void)
254{
255 return 5;
256}
257static inline u32 fb_mmu_invalidate_cancel_gpc_id_f(u32 v)
258{
259 return (v & 0x1f) << 15;
260}
261static inline u32 fb_mmu_invalidate_cancel_gpc_id_m(void)
262{
263 return 0x1f << 15;
264}
265static inline u32 fb_mmu_invalidate_cancel_gpc_id_v(u32 r)
266{
267 return (r >> 15) & 0x1f;
268}
269static inline u32 fb_mmu_invalidate_cancel_client_type_s(void)
270{
271 return 1;
272}
273static inline u32 fb_mmu_invalidate_cancel_client_type_f(u32 v)
274{
275 return (v & 0x1) << 20;
276}
277static inline u32 fb_mmu_invalidate_cancel_client_type_m(void)
278{
279 return 0x1 << 20;
280}
281static inline u32 fb_mmu_invalidate_cancel_client_type_v(u32 r)
282{
283 return (r >> 20) & 0x1;
284}
285static inline u32 fb_mmu_invalidate_cancel_client_type_gpc_f(void)
286{
287 return 0x0;
288}
289static inline u32 fb_mmu_invalidate_cancel_client_type_hub_f(void)
290{
291 return 0x100000;
292}
293static inline u32 fb_mmu_invalidate_cancel_cache_level_s(void)
294{
295 return 3;
296}
297static inline u32 fb_mmu_invalidate_cancel_cache_level_f(u32 v)
298{
299 return (v & 0x7) << 24;
300}
301static inline u32 fb_mmu_invalidate_cancel_cache_level_m(void)
302{
303 return 0x7 << 24;
304}
305static inline u32 fb_mmu_invalidate_cancel_cache_level_v(u32 r)
306{
307 return (r >> 24) & 0x7;
308}
309static inline u32 fb_mmu_invalidate_cancel_cache_level_all_f(void)
310{
311 return 0x0;
312}
313static inline u32 fb_mmu_invalidate_cancel_cache_level_pte_only_f(void)
314{
315 return 0x1000000;
316}
317static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde0_f(void)
318{
319 return 0x2000000;
320}
321static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde1_f(void)
322{
323 return 0x3000000;
324}
325static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde2_f(void)
326{
327 return 0x4000000;
328}
329static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde3_f(void)
330{
331 return 0x5000000;
332}
333static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde4_f(void)
334{
335 return 0x6000000;
336}
337static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde5_f(void)
338{
339 return 0x7000000;
340}
341static inline u32 fb_mmu_invalidate_trigger_s(void)
342{
343 return 1;
344}
345static inline u32 fb_mmu_invalidate_trigger_f(u32 v)
346{
347 return (v & 0x1) << 31;
348}
349static inline u32 fb_mmu_invalidate_trigger_m(void)
350{
351 return 0x1 << 31;
352}
353static inline u32 fb_mmu_invalidate_trigger_v(u32 r)
354{
355 return (r >> 31) & 0x1;
356}
357static inline u32 fb_mmu_invalidate_trigger_true_f(void)
358{
359 return 0x80000000;
360}
361static inline u32 fb_mmu_debug_wr_r(void)
362{
363 return 0x00100cc8;
364}
365static inline u32 fb_mmu_debug_wr_aperture_s(void)
366{
367 return 2;
368}
369static inline u32 fb_mmu_debug_wr_aperture_f(u32 v)
370{
371 return (v & 0x3) << 0;
372}
373static inline u32 fb_mmu_debug_wr_aperture_m(void)
374{
375 return 0x3 << 0;
376}
377static inline u32 fb_mmu_debug_wr_aperture_v(u32 r)
378{
379 return (r >> 0) & 0x3;
380}
381static inline u32 fb_mmu_debug_wr_aperture_vid_mem_f(void)
382{
383 return 0x0;
384}
385static inline u32 fb_mmu_debug_wr_aperture_sys_mem_coh_f(void)
386{
387 return 0x2;
388}
389static inline u32 fb_mmu_debug_wr_aperture_sys_mem_ncoh_f(void)
390{
391 return 0x3;
392}
393static inline u32 fb_mmu_debug_wr_vol_false_f(void)
394{
395 return 0x0;
396}
397static inline u32 fb_mmu_debug_wr_vol_true_v(void)
398{
399 return 0x00000001;
400}
401static inline u32 fb_mmu_debug_wr_vol_true_f(void)
402{
403 return 0x4;
404}
405static inline u32 fb_mmu_debug_wr_addr_f(u32 v)
406{
407 return (v & 0xfffffff) << 4;
408}
409static inline u32 fb_mmu_debug_wr_addr_alignment_v(void)
410{
411 return 0x0000000c;
412}
413static inline u32 fb_mmu_debug_rd_r(void)
414{
415 return 0x00100ccc;
416}
417static inline u32 fb_mmu_debug_rd_aperture_vid_mem_f(void)
418{
419 return 0x0;
420}
421static inline u32 fb_mmu_debug_rd_aperture_sys_mem_coh_f(void)
422{
423 return 0x2;
424}
425static inline u32 fb_mmu_debug_rd_aperture_sys_mem_ncoh_f(void)
426{
427 return 0x3;
428}
429static inline u32 fb_mmu_debug_rd_vol_false_f(void)
430{
431 return 0x0;
432}
433static inline u32 fb_mmu_debug_rd_addr_f(u32 v)
434{
435 return (v & 0xfffffff) << 4;
436}
437static inline u32 fb_mmu_debug_rd_addr_alignment_v(void)
438{
439 return 0x0000000c;
440}
441static inline u32 fb_mmu_debug_ctrl_r(void)
442{
443 return 0x00100cc4;
444}
445static inline u32 fb_mmu_debug_ctrl_debug_v(u32 r)
446{
447 return (r >> 16) & 0x1;
448}
449static inline u32 fb_mmu_debug_ctrl_debug_m(void)
450{
451 return 0x1 << 16;
452}
453static inline u32 fb_mmu_debug_ctrl_debug_enabled_v(void)
454{
455 return 0x00000001;
456}
457static inline u32 fb_mmu_debug_ctrl_debug_enabled_f(void)
458{
459 return 0x10000;
460}
461static inline u32 fb_mmu_debug_ctrl_debug_disabled_v(void)
462{
463 return 0x00000000;
464}
465static inline u32 fb_mmu_debug_ctrl_debug_disabled_f(void)
466{
467 return 0x0;
468}
469static inline u32 fb_mmu_vpr_info_r(void)
470{
471 return 0x00100cd0;
472}
473static inline u32 fb_mmu_vpr_info_fetch_v(u32 r)
474{
475 return (r >> 2) & 0x1;
476}
477static inline u32 fb_mmu_vpr_info_fetch_false_v(void)
478{
479 return 0x00000000;
480}
481static inline u32 fb_mmu_vpr_info_fetch_true_v(void)
482{
483 return 0x00000001;
484}
485static inline u32 fb_niso_flush_sysmem_addr_r(void)
486{
487 return 0x00100c10;
488}
489static inline u32 fb_mmu_local_memory_range_r(void)
490{
491 return 0x00100ce0;
492}
493static inline u32 fb_mmu_local_memory_range_lower_scale_v(u32 r)
494{
495 return (r >> 0) & 0xf;
496}
497static inline u32 fb_mmu_local_memory_range_lower_mag_v(u32 r)
498{
499 return (r >> 4) & 0x3f;
500}
501static inline u32 fb_mmu_local_memory_range_ecc_mode_v(u32 r)
502{
503 return (r >> 30) & 0x1;
504}
505static inline u32 fb_fbpa_fbio_delay_r(void)
506{
507 return 0x9a065c;
508}
509static inline u32 fb_fbpa_fbio_delay_src_m(void)
510{
511 return 0x7;
512}
513static inline u32 fb_fbpa_fbio_delay_src_v(u32 r)
514{
515 return (r >> 0) & 0x7;
516}
517static inline u32 fb_fbpa_fbio_delay_src_f(u32 v)
518{
519 return (v & 0x7) << 0;
520}
521static inline u32 fb_fbpa_fbio_delay_src_max_v(void)
522{
523 return 2;
524}
525static inline u32 fb_fbpa_fbio_delay_priv_m(void)
526{
527 return 0x7 << 4;
528}
529static inline u32 fb_fbpa_fbio_delay_priv_v(u32 r)
530{
531 return (r >> 4) & 0x7;
532}
533static inline u32 fb_fbpa_fbio_delay_priv_f(u32 v)
534{
535 return (v & 0x7) << 4;
536}
537static inline u32 fb_fbpa_fbio_delay_priv_max_v(void)
538{
539 return 2;
540}
541static inline u32 fb_fbpa_fbio_cmd_delay_r(void)
542{
543 return 0x9a08e0;
544}
545static inline u32 fb_fbpa_fbio_cmd_delay_cmd_src_m(void)
546{
547 return 0x7;
548}
549static inline u32 fb_fbpa_fbio_cmd_delay_cmd_src_v(u32 r)
550{
551 return (r >> 0) & 0x7;
552}
553static inline u32 fb_fbpa_fbio_cmd_delay_cmd_src_f(u32 v)
554{
555 return (v & 0x7) << 0;
556}
557static inline u32 fb_fbpa_fbio_cmd_delay_cmd_src_max_v(void)
558{
559 return 1;
560}
561static inline u32 fb_fbpa_fbio_cmd_delay_cmd_priv_m(void)
562{
563 return 0x7 << 4;
564}
565static inline u32 fb_fbpa_fbio_cmd_delay_cmd_priv_v(u32 r)
566{
567 return (r >> 4) & 0x7;
568}
569static inline u32 fb_fbpa_fbio_cmd_delay_cmd_priv_f(u32 v)
570{
571 return (v & 0x7) << 4;
572}
573static inline u32 fb_fbpa_fbio_cmd_delay_cmd_priv_max_v(void)
574{
575 return 1;
576}
577static inline u32 fb_niso_scrubber_status_r(void)
578{
579 return 0x00100b20;
580}
581static inline u32 fb_niso_scrubber_status_flag_s(void)
582{
583 return 1;
584}
585static inline u32 fb_niso_scrubber_status_flag_f(u32 v)
586{
587 return (v & 0x1) << 0;
588}
589static inline u32 fb_niso_scrubber_status_flag_m(void)
590{
591 return 0x1 << 0;
592}
593static inline u32 fb_niso_scrubber_status_flag_v(u32 r)
594{
595 return (r >> 0) & 0x1;
596}
597static inline u32 fb_niso_scrub_status_r(void)
598{
599 return 0x00100b20;
600}
601static inline u32 fb_niso_scrub_status_flag_v(u32 r)
602{
603 return (r >> 0) & 0x1;
604}
605static inline u32 fb_fbpa_fbio_iref_byte_rx_ctrl_r(void)
606{
607 return 0x009a0eb0;
608}
609#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_fbpa_gp106.h b/drivers/gpu/nvgpu/gp106/hw_fbpa_gp106.h
new file mode 100644
index 00000000..7f02eeb6
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_fbpa_gp106.h
@@ -0,0 +1,61 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_fbpa_gp106_h_
51#define _hw_fbpa_gp106_h_
52
53static inline u32 fbpa_cstatus_r(void)
54{
55 return 0x009a020c;
56}
57static inline u32 fbpa_cstatus_ramamount_v(u32 r)
58{
59 return (r >> 0) & 0x1ffff;
60}
61#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_fifo_gp106.h b/drivers/gpu/nvgpu/gp106/hw_fifo_gp106.h
new file mode 100644
index 00000000..ec02257e
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_fifo_gp106.h
@@ -0,0 +1,685 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_fifo_gp106_h_
51#define _hw_fifo_gp106_h_
52
53static inline u32 fifo_bar1_base_r(void)
54{
55 return 0x00002254;
56}
57static inline u32 fifo_bar1_base_ptr_f(u32 v)
58{
59 return (v & 0xfffffff) << 0;
60}
61static inline u32 fifo_bar1_base_ptr_align_shift_v(void)
62{
63 return 0x0000000c;
64}
65static inline u32 fifo_bar1_base_valid_false_f(void)
66{
67 return 0x0;
68}
69static inline u32 fifo_bar1_base_valid_true_f(void)
70{
71 return 0x10000000;
72}
73static inline u32 fifo_runlist_base_r(void)
74{
75 return 0x00002270;
76}
77static inline u32 fifo_runlist_base_ptr_f(u32 v)
78{
79 return (v & 0xfffffff) << 0;
80}
81static inline u32 fifo_runlist_base_target_vid_mem_f(void)
82{
83 return 0x0;
84}
85static inline u32 fifo_runlist_base_target_sys_mem_coh_f(void)
86{
87 return 0x20000000;
88}
89static inline u32 fifo_runlist_base_target_sys_mem_ncoh_f(void)
90{
91 return 0x30000000;
92}
93static inline u32 fifo_runlist_r(void)
94{
95 return 0x00002274;
96}
97static inline u32 fifo_runlist_engine_f(u32 v)
98{
99 return (v & 0xf) << 20;
100}
101static inline u32 fifo_eng_runlist_base_r(u32 i)
102{
103 return 0x00002280 + i*8;
104}
105static inline u32 fifo_eng_runlist_base__size_1_v(void)
106{
107 return 0x00000007;
108}
109static inline u32 fifo_eng_runlist_r(u32 i)
110{
111 return 0x00002284 + i*8;
112}
113static inline u32 fifo_eng_runlist__size_1_v(void)
114{
115 return 0x00000007;
116}
117static inline u32 fifo_eng_runlist_length_f(u32 v)
118{
119 return (v & 0xffff) << 0;
120}
121static inline u32 fifo_eng_runlist_length_max_v(void)
122{
123 return 0x0000ffff;
124}
125static inline u32 fifo_eng_runlist_pending_true_f(void)
126{
127 return 0x100000;
128}
129static inline u32 fifo_pb_timeslice_r(u32 i)
130{
131 return 0x00002350 + i*4;
132}
133static inline u32 fifo_pb_timeslice_timeout_16_f(void)
134{
135 return 0x10;
136}
137static inline u32 fifo_pb_timeslice_timescale_0_f(void)
138{
139 return 0x0;
140}
141static inline u32 fifo_pb_timeslice_enable_true_f(void)
142{
143 return 0x10000000;
144}
145static inline u32 fifo_pbdma_map_r(u32 i)
146{
147 return 0x00002390 + i*4;
148}
149static inline u32 fifo_intr_0_r(void)
150{
151 return 0x00002100;
152}
153static inline u32 fifo_intr_0_bind_error_pending_f(void)
154{
155 return 0x1;
156}
157static inline u32 fifo_intr_0_bind_error_reset_f(void)
158{
159 return 0x1;
160}
161static inline u32 fifo_intr_0_sched_error_pending_f(void)
162{
163 return 0x100;
164}
165static inline u32 fifo_intr_0_sched_error_reset_f(void)
166{
167 return 0x100;
168}
169static inline u32 fifo_intr_0_chsw_error_pending_f(void)
170{
171 return 0x10000;
172}
173static inline u32 fifo_intr_0_chsw_error_reset_f(void)
174{
175 return 0x10000;
176}
177static inline u32 fifo_intr_0_fb_flush_timeout_pending_f(void)
178{
179 return 0x800000;
180}
181static inline u32 fifo_intr_0_fb_flush_timeout_reset_f(void)
182{
183 return 0x800000;
184}
185static inline u32 fifo_intr_0_lb_error_pending_f(void)
186{
187 return 0x1000000;
188}
189static inline u32 fifo_intr_0_lb_error_reset_f(void)
190{
191 return 0x1000000;
192}
193static inline u32 fifo_intr_0_replayable_fault_error_pending_f(void)
194{
195 return 0x2000000;
196}
197static inline u32 fifo_intr_0_dropped_mmu_fault_pending_f(void)
198{
199 return 0x8000000;
200}
201static inline u32 fifo_intr_0_dropped_mmu_fault_reset_f(void)
202{
203 return 0x8000000;
204}
205static inline u32 fifo_intr_0_mmu_fault_pending_f(void)
206{
207 return 0x10000000;
208}
209static inline u32 fifo_intr_0_pbdma_intr_pending_f(void)
210{
211 return 0x20000000;
212}
213static inline u32 fifo_intr_0_runlist_event_pending_f(void)
214{
215 return 0x40000000;
216}
217static inline u32 fifo_intr_0_channel_intr_pending_f(void)
218{
219 return 0x80000000;
220}
221static inline u32 fifo_intr_en_0_r(void)
222{
223 return 0x00002140;
224}
225static inline u32 fifo_intr_en_0_sched_error_f(u32 v)
226{
227 return (v & 0x1) << 8;
228}
229static inline u32 fifo_intr_en_0_sched_error_m(void)
230{
231 return 0x1 << 8;
232}
233static inline u32 fifo_intr_en_0_mmu_fault_f(u32 v)
234{
235 return (v & 0x1) << 28;
236}
237static inline u32 fifo_intr_en_0_mmu_fault_m(void)
238{
239 return 0x1 << 28;
240}
241static inline u32 fifo_intr_en_1_r(void)
242{
243 return 0x00002528;
244}
245static inline u32 fifo_intr_bind_error_r(void)
246{
247 return 0x0000252c;
248}
249static inline u32 fifo_intr_sched_error_r(void)
250{
251 return 0x0000254c;
252}
253static inline u32 fifo_intr_sched_error_code_f(u32 v)
254{
255 return (v & 0xff) << 0;
256}
257static inline u32 fifo_intr_sched_error_code_ctxsw_timeout_v(void)
258{
259 return 0x0000000a;
260}
261static inline u32 fifo_intr_chsw_error_r(void)
262{
263 return 0x0000256c;
264}
265static inline u32 fifo_intr_mmu_fault_id_r(void)
266{
267 return 0x0000259c;
268}
269static inline u32 fifo_intr_mmu_fault_eng_id_graphics_v(void)
270{
271 return 0x00000000;
272}
273static inline u32 fifo_intr_mmu_fault_eng_id_graphics_f(void)
274{
275 return 0x0;
276}
277static inline u32 fifo_intr_mmu_fault_inst_r(u32 i)
278{
279 return 0x00002800 + i*16;
280}
281static inline u32 fifo_intr_mmu_fault_inst_ptr_v(u32 r)
282{
283 return (r >> 0) & 0xfffffff;
284}
285static inline u32 fifo_intr_mmu_fault_inst_ptr_align_shift_v(void)
286{
287 return 0x0000000c;
288}
289static inline u32 fifo_intr_mmu_fault_lo_r(u32 i)
290{
291 return 0x00002804 + i*16;
292}
293static inline u32 fifo_intr_mmu_fault_hi_r(u32 i)
294{
295 return 0x00002808 + i*16;
296}
297static inline u32 fifo_intr_mmu_fault_info_r(u32 i)
298{
299 return 0x0000280c + i*16;
300}
301static inline u32 fifo_intr_mmu_fault_info_type_v(u32 r)
302{
303 return (r >> 0) & 0x1f;
304}
305static inline u32 fifo_intr_mmu_fault_info_client_type_v(u32 r)
306{
307 return (r >> 20) & 0x1;
308}
309static inline u32 fifo_intr_mmu_fault_info_client_type_gpc_v(void)
310{
311 return 0x00000000;
312}
313static inline u32 fifo_intr_mmu_fault_info_client_type_hub_v(void)
314{
315 return 0x00000001;
316}
317static inline u32 fifo_intr_mmu_fault_info_client_v(u32 r)
318{
319 return (r >> 8) & 0x7f;
320}
321static inline u32 fifo_intr_pbdma_id_r(void)
322{
323 return 0x000025a0;
324}
325static inline u32 fifo_intr_pbdma_id_status_f(u32 v, u32 i)
326{
327 return (v & 0x1) << (0 + i*1);
328}
329static inline u32 fifo_intr_pbdma_id_status__size_1_v(void)
330{
331 return 0x00000004;
332}
333static inline u32 fifo_intr_runlist_r(void)
334{
335 return 0x00002a00;
336}
337static inline u32 fifo_fb_timeout_r(void)
338{
339 return 0x00002a04;
340}
341static inline u32 fifo_fb_timeout_period_m(void)
342{
343 return 0x3fffffff << 0;
344}
345static inline u32 fifo_fb_timeout_period_max_f(void)
346{
347 return 0x3fffffff;
348}
349static inline u32 fifo_error_sched_disable_r(void)
350{
351 return 0x0000262c;
352}
353static inline u32 fifo_sched_disable_r(void)
354{
355 return 0x00002630;
356}
357static inline u32 fifo_sched_disable_runlist_f(u32 v, u32 i)
358{
359 return (v & 0x1) << (0 + i*1);
360}
361static inline u32 fifo_sched_disable_runlist_m(u32 i)
362{
363 return 0x1 << (0 + i*1);
364}
365static inline u32 fifo_sched_disable_true_v(void)
366{
367 return 0x00000001;
368}
369static inline u32 fifo_preempt_r(void)
370{
371 return 0x00002634;
372}
373static inline u32 fifo_preempt_pending_true_f(void)
374{
375 return 0x100000;
376}
377static inline u32 fifo_preempt_type_channel_f(void)
378{
379 return 0x0;
380}
381static inline u32 fifo_preempt_type_tsg_f(void)
382{
383 return 0x1000000;
384}
385static inline u32 fifo_preempt_chid_f(u32 v)
386{
387 return (v & 0xfff) << 0;
388}
389static inline u32 fifo_preempt_id_f(u32 v)
390{
391 return (v & 0xfff) << 0;
392}
393static inline u32 fifo_trigger_mmu_fault_r(u32 i)
394{
395 return 0x00002a30 + i*4;
396}
397static inline u32 fifo_trigger_mmu_fault_id_f(u32 v)
398{
399 return (v & 0x1f) << 0;
400}
401static inline u32 fifo_trigger_mmu_fault_enable_f(u32 v)
402{
403 return (v & 0x1) << 8;
404}
405static inline u32 fifo_engine_status_r(u32 i)
406{
407 return 0x00002640 + i*8;
408}
409static inline u32 fifo_engine_status__size_1_v(void)
410{
411 return 0x00000009;
412}
413static inline u32 fifo_engine_status_id_v(u32 r)
414{
415 return (r >> 0) & 0xfff;
416}
417static inline u32 fifo_engine_status_id_type_v(u32 r)
418{
419 return (r >> 12) & 0x1;
420}
421static inline u32 fifo_engine_status_id_type_chid_v(void)
422{
423 return 0x00000000;
424}
425static inline u32 fifo_engine_status_id_type_tsgid_v(void)
426{
427 return 0x00000001;
428}
429static inline u32 fifo_engine_status_ctx_status_v(u32 r)
430{
431 return (r >> 13) & 0x7;
432}
433static inline u32 fifo_engine_status_ctx_status_invalid_v(void)
434{
435 return 0x00000000;
436}
437static inline u32 fifo_engine_status_ctx_status_valid_v(void)
438{
439 return 0x00000001;
440}
441static inline u32 fifo_engine_status_ctx_status_ctxsw_load_v(void)
442{
443 return 0x00000005;
444}
445static inline u32 fifo_engine_status_ctx_status_ctxsw_save_v(void)
446{
447 return 0x00000006;
448}
449static inline u32 fifo_engine_status_ctx_status_ctxsw_switch_v(void)
450{
451 return 0x00000007;
452}
453static inline u32 fifo_engine_status_next_id_v(u32 r)
454{
455 return (r >> 16) & 0xfff;
456}
457static inline u32 fifo_engine_status_next_id_type_v(u32 r)
458{
459 return (r >> 28) & 0x1;
460}
461static inline u32 fifo_engine_status_next_id_type_chid_v(void)
462{
463 return 0x00000000;
464}
465static inline u32 fifo_engine_status_faulted_v(u32 r)
466{
467 return (r >> 30) & 0x1;
468}
469static inline u32 fifo_engine_status_faulted_true_v(void)
470{
471 return 0x00000001;
472}
473static inline u32 fifo_engine_status_engine_v(u32 r)
474{
475 return (r >> 31) & 0x1;
476}
477static inline u32 fifo_engine_status_engine_idle_v(void)
478{
479 return 0x00000000;
480}
481static inline u32 fifo_engine_status_engine_busy_v(void)
482{
483 return 0x00000001;
484}
485static inline u32 fifo_engine_status_ctxsw_v(u32 r)
486{
487 return (r >> 15) & 0x1;
488}
489static inline u32 fifo_engine_status_ctxsw_in_progress_v(void)
490{
491 return 0x00000001;
492}
493static inline u32 fifo_engine_status_ctxsw_in_progress_f(void)
494{
495 return 0x8000;
496}
497static inline u32 fifo_pbdma_status_r(u32 i)
498{
499 return 0x00003080 + i*4;
500}
501static inline u32 fifo_pbdma_status__size_1_v(void)
502{
503 return 0x00000004;
504}
505static inline u32 fifo_pbdma_status_id_v(u32 r)
506{
507 return (r >> 0) & 0xfff;
508}
509static inline u32 fifo_pbdma_status_id_type_v(u32 r)
510{
511 return (r >> 12) & 0x1;
512}
513static inline u32 fifo_pbdma_status_id_type_chid_v(void)
514{
515 return 0x00000000;
516}
517static inline u32 fifo_pbdma_status_id_type_tsgid_v(void)
518{
519 return 0x00000001;
520}
521static inline u32 fifo_pbdma_status_chan_status_v(u32 r)
522{
523 return (r >> 13) & 0x7;
524}
525static inline u32 fifo_pbdma_status_chan_status_valid_v(void)
526{
527 return 0x00000001;
528}
529static inline u32 fifo_pbdma_status_chan_status_chsw_load_v(void)
530{
531 return 0x00000005;
532}
533static inline u32 fifo_pbdma_status_chan_status_chsw_save_v(void)
534{
535 return 0x00000006;
536}
537static inline u32 fifo_pbdma_status_chan_status_chsw_switch_v(void)
538{
539 return 0x00000007;
540}
541static inline u32 fifo_pbdma_status_next_id_v(u32 r)
542{
543 return (r >> 16) & 0xfff;
544}
545static inline u32 fifo_pbdma_status_next_id_type_v(u32 r)
546{
547 return (r >> 28) & 0x1;
548}
549static inline u32 fifo_pbdma_status_next_id_type_chid_v(void)
550{
551 return 0x00000000;
552}
553static inline u32 fifo_pbdma_status_chsw_v(u32 r)
554{
555 return (r >> 15) & 0x1;
556}
557static inline u32 fifo_pbdma_status_chsw_in_progress_v(void)
558{
559 return 0x00000001;
560}
561static inline u32 fifo_replay_fault_buffer_lo_r(void)
562{
563 return 0x00002a70;
564}
565static inline u32 fifo_replay_fault_buffer_lo_enable_v(u32 r)
566{
567 return (r >> 0) & 0x1;
568}
569static inline u32 fifo_replay_fault_buffer_lo_enable_true_v(void)
570{
571 return 0x00000001;
572}
573static inline u32 fifo_replay_fault_buffer_lo_enable_false_v(void)
574{
575 return 0x00000000;
576}
577static inline u32 fifo_replay_fault_buffer_lo_base_f(u32 v)
578{
579 return (v & 0xfffff) << 12;
580}
581static inline u32 fifo_replay_fault_buffer_lo_base_reset_v(void)
582{
583 return 0x00000000;
584}
585static inline u32 fifo_replay_fault_buffer_hi_r(void)
586{
587 return 0x00002a74;
588}
589static inline u32 fifo_replay_fault_buffer_hi_base_f(u32 v)
590{
591 return (v & 0xff) << 0;
592}
593static inline u32 fifo_replay_fault_buffer_hi_base_reset_v(void)
594{
595 return 0x00000000;
596}
597static inline u32 fifo_replay_fault_buffer_size_r(void)
598{
599 return 0x00002a78;
600}
601static inline u32 fifo_replay_fault_buffer_size_hw_f(u32 v)
602{
603 return (v & 0x3fff) << 0;
604}
605static inline u32 fifo_replay_fault_buffer_size_hw_entries_v(void)
606{
607 return 0x00001200;
608}
609static inline u32 fifo_replay_fault_buffer_get_r(void)
610{
611 return 0x00002a7c;
612}
613static inline u32 fifo_replay_fault_buffer_get_offset_hw_f(u32 v)
614{
615 return (v & 0x3fff) << 0;
616}
617static inline u32 fifo_replay_fault_buffer_get_offset_hw_init_v(void)
618{
619 return 0x00000000;
620}
621static inline u32 fifo_replay_fault_buffer_put_r(void)
622{
623 return 0x00002a80;
624}
625static inline u32 fifo_replay_fault_buffer_put_offset_hw_f(u32 v)
626{
627 return (v & 0x3fff) << 0;
628}
629static inline u32 fifo_replay_fault_buffer_put_offset_hw_init_v(void)
630{
631 return 0x00000000;
632}
633static inline u32 fifo_replay_fault_buffer_info_r(void)
634{
635 return 0x00002a84;
636}
637static inline u32 fifo_replay_fault_buffer_info_overflow_f(u32 v)
638{
639 return (v & 0x1) << 0;
640}
641static inline u32 fifo_replay_fault_buffer_info_overflow_false_v(void)
642{
643 return 0x00000000;
644}
645static inline u32 fifo_replay_fault_buffer_info_overflow_true_v(void)
646{
647 return 0x00000001;
648}
649static inline u32 fifo_replay_fault_buffer_info_overflow_clear_v(void)
650{
651 return 0x00000001;
652}
653static inline u32 fifo_replay_fault_buffer_info_write_nack_f(u32 v)
654{
655 return (v & 0x1) << 24;
656}
657static inline u32 fifo_replay_fault_buffer_info_write_nack_false_v(void)
658{
659 return 0x00000000;
660}
661static inline u32 fifo_replay_fault_buffer_info_write_nack_true_v(void)
662{
663 return 0x00000001;
664}
665static inline u32 fifo_replay_fault_buffer_info_write_nack_clear_v(void)
666{
667 return 0x00000001;
668}
669static inline u32 fifo_replay_fault_buffer_info_fault_while_buffer_disabled_f(u32 v)
670{
671 return (v & 0x1) << 28;
672}
673static inline u32 fifo_replay_fault_buffer_info_fault_while_buffer_disabled_false_v(void)
674{
675 return 0x00000000;
676}
677static inline u32 fifo_replay_fault_buffer_info_fault_while_buffer_disabled_true_v(void)
678{
679 return 0x00000001;
680}
681static inline u32 fifo_replay_fault_buffer_info_fault_while_buffer_disabled_clear_v(void)
682{
683 return 0x00000001;
684}
685#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_flush_gp106.h b/drivers/gpu/nvgpu/gp106/hw_flush_gp106.h
new file mode 100644
index 00000000..83bd65bb
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_flush_gp106.h
@@ -0,0 +1,181 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_flush_gp106_h_
51#define _hw_flush_gp106_h_
52
53static inline u32 flush_l2_system_invalidate_r(void)
54{
55 return 0x00070004;
56}
57static inline u32 flush_l2_system_invalidate_pending_v(u32 r)
58{
59 return (r >> 0) & 0x1;
60}
61static inline u32 flush_l2_system_invalidate_pending_busy_v(void)
62{
63 return 0x00000001;
64}
65static inline u32 flush_l2_system_invalidate_pending_busy_f(void)
66{
67 return 0x1;
68}
69static inline u32 flush_l2_system_invalidate_outstanding_v(u32 r)
70{
71 return (r >> 1) & 0x1;
72}
73static inline u32 flush_l2_system_invalidate_outstanding_true_v(void)
74{
75 return 0x00000001;
76}
77static inline u32 flush_l2_flush_dirty_r(void)
78{
79 return 0x00070010;
80}
81static inline u32 flush_l2_flush_dirty_pending_v(u32 r)
82{
83 return (r >> 0) & 0x1;
84}
85static inline u32 flush_l2_flush_dirty_pending_empty_v(void)
86{
87 return 0x00000000;
88}
89static inline u32 flush_l2_flush_dirty_pending_empty_f(void)
90{
91 return 0x0;
92}
93static inline u32 flush_l2_flush_dirty_pending_busy_v(void)
94{
95 return 0x00000001;
96}
97static inline u32 flush_l2_flush_dirty_pending_busy_f(void)
98{
99 return 0x1;
100}
101static inline u32 flush_l2_flush_dirty_outstanding_v(u32 r)
102{
103 return (r >> 1) & 0x1;
104}
105static inline u32 flush_l2_flush_dirty_outstanding_false_v(void)
106{
107 return 0x00000000;
108}
109static inline u32 flush_l2_flush_dirty_outstanding_false_f(void)
110{
111 return 0x0;
112}
113static inline u32 flush_l2_flush_dirty_outstanding_true_v(void)
114{
115 return 0x00000001;
116}
117static inline u32 flush_l2_clean_comptags_r(void)
118{
119 return 0x0007000c;
120}
121static inline u32 flush_l2_clean_comptags_pending_v(u32 r)
122{
123 return (r >> 0) & 0x1;
124}
125static inline u32 flush_l2_clean_comptags_pending_empty_v(void)
126{
127 return 0x00000000;
128}
129static inline u32 flush_l2_clean_comptags_pending_empty_f(void)
130{
131 return 0x0;
132}
133static inline u32 flush_l2_clean_comptags_pending_busy_v(void)
134{
135 return 0x00000001;
136}
137static inline u32 flush_l2_clean_comptags_pending_busy_f(void)
138{
139 return 0x1;
140}
141static inline u32 flush_l2_clean_comptags_outstanding_v(u32 r)
142{
143 return (r >> 1) & 0x1;
144}
145static inline u32 flush_l2_clean_comptags_outstanding_false_v(void)
146{
147 return 0x00000000;
148}
149static inline u32 flush_l2_clean_comptags_outstanding_false_f(void)
150{
151 return 0x0;
152}
153static inline u32 flush_l2_clean_comptags_outstanding_true_v(void)
154{
155 return 0x00000001;
156}
157static inline u32 flush_fb_flush_r(void)
158{
159 return 0x00070000;
160}
161static inline u32 flush_fb_flush_pending_v(u32 r)
162{
163 return (r >> 0) & 0x1;
164}
165static inline u32 flush_fb_flush_pending_busy_v(void)
166{
167 return 0x00000001;
168}
169static inline u32 flush_fb_flush_pending_busy_f(void)
170{
171 return 0x1;
172}
173static inline u32 flush_fb_flush_outstanding_v(u32 r)
174{
175 return (r >> 1) & 0x1;
176}
177static inline u32 flush_fb_flush_outstanding_true_v(void)
178{
179 return 0x00000001;
180}
181#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_fuse_gp106.h b/drivers/gpu/nvgpu/gp106/hw_fuse_gp106.h
new file mode 100644
index 00000000..32d8a4f2
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_fuse_gp106.h
@@ -0,0 +1,217 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_fuse_gp106_h_
51#define _hw_fuse_gp106_h_
52
53static inline u32 fuse_status_opt_tpc_gpc_r(u32 i)
54{
55 return 0x00021c38 + i*4;
56}
57static inline u32 fuse_ctrl_opt_tpc_gpc_r(u32 i)
58{
59 return 0x00021838 + i*4;
60}
61static inline u32 fuse_ctrl_opt_ram_svop_pdp_r(void)
62{
63 return 0x00021944;
64}
65static inline u32 fuse_ctrl_opt_ram_svop_pdp_data_f(u32 v)
66{
67 return (v & 0x3) << 0;
68}
69static inline u32 fuse_ctrl_opt_ram_svop_pdp_data_m(void)
70{
71 return 0x3 << 0;
72}
73static inline u32 fuse_ctrl_opt_ram_svop_pdp_data_v(u32 r)
74{
75 return (r >> 0) & 0x3;
76}
77static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_r(void)
78{
79 return 0x00021948;
80}
81static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_f(u32 v)
82{
83 return (v & 0x1) << 0;
84}
85static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_m(void)
86{
87 return 0x1 << 0;
88}
89static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_v(u32 r)
90{
91 return (r >> 0) & 0x1;
92}
93static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_yes_f(void)
94{
95 return 0x1;
96}
97static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_no_f(void)
98{
99 return 0x0;
100}
101static inline u32 fuse_status_opt_fbio_r(void)
102{
103 return 0x00021c14;
104}
105static inline u32 fuse_status_opt_fbio_data_f(u32 v)
106{
107 return (v & 0xffff) << 0;
108}
109static inline u32 fuse_status_opt_fbio_data_m(void)
110{
111 return 0xffff << 0;
112}
113static inline u32 fuse_status_opt_fbio_data_v(u32 r)
114{
115 return (r >> 0) & 0xffff;
116}
117static inline u32 fuse_status_opt_rop_l2_fbp_r(u32 i)
118{
119 return 0x00021d70 + i*4;
120}
121static inline u32 fuse_status_opt_fbp_r(void)
122{
123 return 0x00021d38;
124}
125static inline u32 fuse_status_opt_fbp_idx_v(u32 r, u32 i)
126{
127 return (r >> (0 + i*0)) & 0x1;
128}
129static inline u32 fuse_vin_cal_fuse_rev_r(void)
130{
131 return 0x0002164c;
132}
133static inline u32 fuse_vin_cal_fuse_rev_v(u32 r)
134{
135 return 0x3 & r;
136}
137static inline u32 fuse_vin_cal_gpc0_r(void)
138{
139 return 0x00021650;
140}
141static inline u32 fuse_vin_cal_gpc0_icpt_data_v(u32 r)
142{
143 return ((r & 0xFFFC000) >> 14);
144}
145static inline u32 fuse_vin_cal_gpc0_icpt_frac_size_v(void)
146{
147 return 2;
148}
149static inline u32 fuse_vin_cal_gpc0_slope_data_v(u32 r)
150{
151 return (r & 0x3FFF);
152}
153static inline u32 fuse_vin_cal_gpc0_slope_frac_size_v(void)
154{
155 return 10;
156}
157static inline u32 fuse_vin_cal_gpc1_delta_r(void)
158{
159 return 0x00021654;
160}
161static inline u32 fuse_vin_cal_gpc1_icpt_sign_f(void)
162{
163 return 0x400000;
164}
165static inline u32 fuse_vin_cal_gpc1_slope_sign_f(void)
166{
167 return 0x800;
168}
169static inline u32 fuse_vin_cal_gpc1_icpt_data_v(u32 r)
170{
171 return ((r & 0x3FF000) >> 12);
172}
173static inline u32 fuse_vin_cal_gpc1_icpt_frac_size_v(void)
174{
175 return 2;
176}
177static inline u32 fuse_vin_cal_gpc1_slope_data_v(u32 r)
178{
179 return (r & 0x7FF);
180}
181static inline u32 fuse_vin_cal_gpc1_slope_frac_size_v(void)
182{
183 return 10;
184}
185static inline u32 fuse_vin_cal_gpc2_delta_r(void)
186{
187 return 0x00021658;
188}
189static inline u32 fuse_vin_cal_gpc3_delta_r(void)
190{
191 return 0x0002165c;
192}
193static inline u32 fuse_vin_cal_gpc4_delta_r(void)
194{
195 return 0x00021660;
196}
197static inline u32 fuse_vin_cal_gpc5_delta_r(void)
198{
199 return 0x00021664;
200}
201static inline u32 fuse_vin_cal_shared_delta_r(void)
202{
203 return 0x00021668;
204}
205static inline u32 fuse_vin_cal_sram_delta_r(void)
206{
207 return 0x0002166c;
208}
209static inline u32 fuse_vin_cal_sram_icpt_data_v(u32 r)
210{
211 return ((r & 0x3FF000) >> 12);
212}
213static inline u32 fuse_vin_cal_sram_icpt_frac_size_v(void)
214{
215 return 1;
216}
217#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_gc6_gp106.h b/drivers/gpu/nvgpu/gp106/hw_gc6_gp106.h
new file mode 100644
index 00000000..25aca9b5
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_gc6_gp106.h
@@ -0,0 +1,56 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_gc6_gp106_h_
51#define _hw_gc6_gp106_h_
52static inline u32 gc6_sci_strap_r(void)
53{
54 return 0x00010ebb0;
55}
56#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_gmmu_gp106.h b/drivers/gpu/nvgpu/gp106/hw_gmmu_gp106.h
new file mode 100644
index 00000000..96ab77df
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_gmmu_gp106.h
@@ -0,0 +1,1261 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_gmmu_gp106_h_
51#define _hw_gmmu_gp106_h_
52
53static inline u32 gmmu_new_pde_is_pte_w(void)
54{
55 return 0;
56}
57static inline u32 gmmu_new_pde_is_pte_false_f(void)
58{
59 return 0x0;
60}
61static inline u32 gmmu_new_pde_aperture_w(void)
62{
63 return 0;
64}
65static inline u32 gmmu_new_pde_aperture_invalid_f(void)
66{
67 return 0x0;
68}
69static inline u32 gmmu_new_pde_aperture_video_memory_f(void)
70{
71 return 0x2;
72}
73static inline u32 gmmu_new_pde_aperture_sys_mem_coh_f(void)
74{
75 return 0x4;
76}
77static inline u32 gmmu_new_pde_aperture_sys_mem_ncoh_f(void)
78{
79 return 0x6;
80}
81static inline u32 gmmu_new_pde_address_sys_f(u32 v)
82{
83 return (v & 0xffffff) << 8;
84}
85static inline u32 gmmu_new_pde_address_sys_w(void)
86{
87 return 0;
88}
89static inline u32 gmmu_new_pde_vol_w(void)
90{
91 return 0;
92}
93static inline u32 gmmu_new_pde_vol_true_f(void)
94{
95 return 0x8;
96}
97static inline u32 gmmu_new_pde_vol_false_f(void)
98{
99 return 0x0;
100}
101static inline u32 gmmu_new_pde_address_shift_v(void)
102{
103 return 0x0000000c;
104}
105static inline u32 gmmu_new_pde__size_v(void)
106{
107 return 0x00000008;
108}
109static inline u32 gmmu_new_dual_pde_is_pte_w(void)
110{
111 return 0;
112}
113static inline u32 gmmu_new_dual_pde_is_pte_false_f(void)
114{
115 return 0x0;
116}
117static inline u32 gmmu_new_dual_pde_aperture_big_w(void)
118{
119 return 0;
120}
121static inline u32 gmmu_new_dual_pde_aperture_big_invalid_f(void)
122{
123 return 0x0;
124}
125static inline u32 gmmu_new_dual_pde_aperture_big_video_memory_f(void)
126{
127 return 0x2;
128}
129static inline u32 gmmu_new_dual_pde_aperture_big_sys_mem_coh_f(void)
130{
131 return 0x4;
132}
133static inline u32 gmmu_new_dual_pde_aperture_big_sys_mem_ncoh_f(void)
134{
135 return 0x6;
136}
137static inline u32 gmmu_new_dual_pde_address_big_sys_f(u32 v)
138{
139 return (v & 0xfffffff) << 4;
140}
141static inline u32 gmmu_new_dual_pde_address_big_sys_w(void)
142{
143 return 0;
144}
145static inline u32 gmmu_new_dual_pde_aperture_small_w(void)
146{
147 return 2;
148}
149static inline u32 gmmu_new_dual_pde_aperture_small_invalid_f(void)
150{
151 return 0x0;
152}
153static inline u32 gmmu_new_dual_pde_aperture_small_video_memory_f(void)
154{
155 return 0x2;
156}
157static inline u32 gmmu_new_dual_pde_aperture_small_sys_mem_coh_f(void)
158{
159 return 0x4;
160}
161static inline u32 gmmu_new_dual_pde_aperture_small_sys_mem_ncoh_f(void)
162{
163 return 0x6;
164}
165static inline u32 gmmu_new_dual_pde_vol_small_w(void)
166{
167 return 2;
168}
169static inline u32 gmmu_new_dual_pde_vol_small_true_f(void)
170{
171 return 0x8;
172}
173static inline u32 gmmu_new_dual_pde_vol_small_false_f(void)
174{
175 return 0x0;
176}
177static inline u32 gmmu_new_dual_pde_vol_big_w(void)
178{
179 return 0;
180}
181static inline u32 gmmu_new_dual_pde_vol_big_true_f(void)
182{
183 return 0x8;
184}
185static inline u32 gmmu_new_dual_pde_vol_big_false_f(void)
186{
187 return 0x0;
188}
189static inline u32 gmmu_new_dual_pde_address_small_sys_f(u32 v)
190{
191 return (v & 0xffffff) << 8;
192}
193static inline u32 gmmu_new_dual_pde_address_small_sys_w(void)
194{
195 return 2;
196}
197static inline u32 gmmu_new_dual_pde_address_shift_v(void)
198{
199 return 0x0000000c;
200}
201static inline u32 gmmu_new_dual_pde_address_big_shift_v(void)
202{
203 return 0x00000008;
204}
205static inline u32 gmmu_new_dual_pde__size_v(void)
206{
207 return 0x00000010;
208}
209static inline u32 gmmu_new_pte__size_v(void)
210{
211 return 0x00000008;
212}
213static inline u32 gmmu_new_pte_valid_w(void)
214{
215 return 0;
216}
217static inline u32 gmmu_new_pte_valid_true_f(void)
218{
219 return 0x1;
220}
221static inline u32 gmmu_new_pte_valid_false_f(void)
222{
223 return 0x0;
224}
225static inline u32 gmmu_new_pte_privilege_w(void)
226{
227 return 0;
228}
229static inline u32 gmmu_new_pte_privilege_true_f(void)
230{
231 return 0x20;
232}
233static inline u32 gmmu_new_pte_privilege_false_f(void)
234{
235 return 0x0;
236}
237static inline u32 gmmu_new_pte_address_sys_f(u32 v)
238{
239 return (v & 0xffffff) << 8;
240}
241static inline u32 gmmu_new_pte_address_sys_w(void)
242{
243 return 0;
244}
245static inline u32 gmmu_new_pte_vol_w(void)
246{
247 return 0;
248}
249static inline u32 gmmu_new_pte_vol_true_f(void)
250{
251 return 0x8;
252}
253static inline u32 gmmu_new_pte_vol_false_f(void)
254{
255 return 0x0;
256}
257static inline u32 gmmu_new_pte_aperture_w(void)
258{
259 return 0;
260}
261static inline u32 gmmu_new_pte_aperture_video_memory_f(void)
262{
263 return 0x0;
264}
265static inline u32 gmmu_new_pte_aperture_sys_mem_coh_f(void)
266{
267 return 0x4;
268}
269static inline u32 gmmu_new_pte_aperture_sys_mem_ncoh_f(void)
270{
271 return 0x6;
272}
273static inline u32 gmmu_new_pte_read_only_w(void)
274{
275 return 0;
276}
277static inline u32 gmmu_new_pte_read_only_true_f(void)
278{
279 return 0x40;
280}
281static inline u32 gmmu_new_pte_comptagline_f(u32 v)
282{
283 return (v & 0x3ffff) << 4;
284}
285static inline u32 gmmu_new_pte_comptagline_w(void)
286{
287 return 1;
288}
289static inline u32 gmmu_new_pte_kind_f(u32 v)
290{
291 return (v & 0xff) << 24;
292}
293static inline u32 gmmu_new_pte_kind_w(void)
294{
295 return 1;
296}
297static inline u32 gmmu_new_pte_address_shift_v(void)
298{
299 return 0x0000000c;
300}
301static inline u32 gmmu_pte_kind_f(u32 v)
302{
303 return (v & 0xff) << 4;
304}
305static inline u32 gmmu_pte_kind_w(void)
306{
307 return 1;
308}
309static inline u32 gmmu_pte_kind_invalid_v(void)
310{
311 return 0x000000ff;
312}
313static inline u32 gmmu_pte_kind_pitch_v(void)
314{
315 return 0x00000000;
316}
317static inline u32 gmmu_pte_kind_z16_v(void)
318{
319 return 0x00000001;
320}
321static inline u32 gmmu_pte_kind_z16_2c_v(void)
322{
323 return 0x00000002;
324}
325static inline u32 gmmu_pte_kind_z16_ms2_2c_v(void)
326{
327 return 0x00000003;
328}
329static inline u32 gmmu_pte_kind_z16_ms4_2c_v(void)
330{
331 return 0x00000004;
332}
333static inline u32 gmmu_pte_kind_z16_ms8_2c_v(void)
334{
335 return 0x00000005;
336}
337static inline u32 gmmu_pte_kind_z16_ms16_2c_v(void)
338{
339 return 0x00000006;
340}
341static inline u32 gmmu_pte_kind_z16_2z_v(void)
342{
343 return 0x00000007;
344}
345static inline u32 gmmu_pte_kind_z16_ms2_2z_v(void)
346{
347 return 0x00000008;
348}
349static inline u32 gmmu_pte_kind_z16_ms4_2z_v(void)
350{
351 return 0x00000009;
352}
353static inline u32 gmmu_pte_kind_z16_ms8_2z_v(void)
354{
355 return 0x0000000a;
356}
357static inline u32 gmmu_pte_kind_z16_ms16_2z_v(void)
358{
359 return 0x0000000b;
360}
361static inline u32 gmmu_pte_kind_z16_2cz_v(void)
362{
363 return 0x00000036;
364}
365static inline u32 gmmu_pte_kind_z16_ms2_2cz_v(void)
366{
367 return 0x00000037;
368}
369static inline u32 gmmu_pte_kind_z16_ms4_2cz_v(void)
370{
371 return 0x00000038;
372}
373static inline u32 gmmu_pte_kind_z16_ms8_2cz_v(void)
374{
375 return 0x00000039;
376}
377static inline u32 gmmu_pte_kind_z16_ms16_2cz_v(void)
378{
379 return 0x0000005f;
380}
381static inline u32 gmmu_pte_kind_z16_4cz_v(void)
382{
383 return 0x0000000c;
384}
385static inline u32 gmmu_pte_kind_z16_ms2_4cz_v(void)
386{
387 return 0x0000000d;
388}
389static inline u32 gmmu_pte_kind_z16_ms4_4cz_v(void)
390{
391 return 0x0000000e;
392}
393static inline u32 gmmu_pte_kind_z16_ms8_4cz_v(void)
394{
395 return 0x0000000f;
396}
397static inline u32 gmmu_pte_kind_z16_ms16_4cz_v(void)
398{
399 return 0x00000010;
400}
401static inline u32 gmmu_pte_kind_s8z24_v(void)
402{
403 return 0x00000011;
404}
405static inline u32 gmmu_pte_kind_s8z24_1z_v(void)
406{
407 return 0x00000012;
408}
409static inline u32 gmmu_pte_kind_s8z24_ms2_1z_v(void)
410{
411 return 0x00000013;
412}
413static inline u32 gmmu_pte_kind_s8z24_ms4_1z_v(void)
414{
415 return 0x00000014;
416}
417static inline u32 gmmu_pte_kind_s8z24_ms8_1z_v(void)
418{
419 return 0x00000015;
420}
421static inline u32 gmmu_pte_kind_s8z24_ms16_1z_v(void)
422{
423 return 0x00000016;
424}
425static inline u32 gmmu_pte_kind_s8z24_2cz_v(void)
426{
427 return 0x00000017;
428}
429static inline u32 gmmu_pte_kind_s8z24_ms2_2cz_v(void)
430{
431 return 0x00000018;
432}
433static inline u32 gmmu_pte_kind_s8z24_ms4_2cz_v(void)
434{
435 return 0x00000019;
436}
437static inline u32 gmmu_pte_kind_s8z24_ms8_2cz_v(void)
438{
439 return 0x0000001a;
440}
441static inline u32 gmmu_pte_kind_s8z24_ms16_2cz_v(void)
442{
443 return 0x0000001b;
444}
445static inline u32 gmmu_pte_kind_s8z24_2cs_v(void)
446{
447 return 0x0000001c;
448}
449static inline u32 gmmu_pte_kind_s8z24_ms2_2cs_v(void)
450{
451 return 0x0000001d;
452}
453static inline u32 gmmu_pte_kind_s8z24_ms4_2cs_v(void)
454{
455 return 0x0000001e;
456}
457static inline u32 gmmu_pte_kind_s8z24_ms8_2cs_v(void)
458{
459 return 0x0000001f;
460}
461static inline u32 gmmu_pte_kind_s8z24_ms16_2cs_v(void)
462{
463 return 0x00000020;
464}
465static inline u32 gmmu_pte_kind_s8z24_4cszv_v(void)
466{
467 return 0x00000021;
468}
469static inline u32 gmmu_pte_kind_s8z24_ms2_4cszv_v(void)
470{
471 return 0x00000022;
472}
473static inline u32 gmmu_pte_kind_s8z24_ms4_4cszv_v(void)
474{
475 return 0x00000023;
476}
477static inline u32 gmmu_pte_kind_s8z24_ms8_4cszv_v(void)
478{
479 return 0x00000024;
480}
481static inline u32 gmmu_pte_kind_s8z24_ms16_4cszv_v(void)
482{
483 return 0x00000025;
484}
485static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_v(void)
486{
487 return 0x00000026;
488}
489static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_v(void)
490{
491 return 0x00000027;
492}
493static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_v(void)
494{
495 return 0x00000028;
496}
497static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_v(void)
498{
499 return 0x00000029;
500}
501static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_1zv_v(void)
502{
503 return 0x0000002e;
504}
505static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_1zv_v(void)
506{
507 return 0x0000002f;
508}
509static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_1zv_v(void)
510{
511 return 0x00000030;
512}
513static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_1zv_v(void)
514{
515 return 0x00000031;
516}
517static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_2cs_v(void)
518{
519 return 0x00000032;
520}
521static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_2cs_v(void)
522{
523 return 0x00000033;
524}
525static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_2cs_v(void)
526{
527 return 0x00000034;
528}
529static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_2cs_v(void)
530{
531 return 0x00000035;
532}
533static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_2czv_v(void)
534{
535 return 0x0000003a;
536}
537static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_2czv_v(void)
538{
539 return 0x0000003b;
540}
541static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_2czv_v(void)
542{
543 return 0x0000003c;
544}
545static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_2czv_v(void)
546{
547 return 0x0000003d;
548}
549static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_2zv_v(void)
550{
551 return 0x0000003e;
552}
553static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_2zv_v(void)
554{
555 return 0x0000003f;
556}
557static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_2zv_v(void)
558{
559 return 0x00000040;
560}
561static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_2zv_v(void)
562{
563 return 0x00000041;
564}
565static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_4cszv_v(void)
566{
567 return 0x00000042;
568}
569static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_4cszv_v(void)
570{
571 return 0x00000043;
572}
573static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_4cszv_v(void)
574{
575 return 0x00000044;
576}
577static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_4cszv_v(void)
578{
579 return 0x00000045;
580}
581static inline u32 gmmu_pte_kind_z24s8_v(void)
582{
583 return 0x00000046;
584}
585static inline u32 gmmu_pte_kind_z24s8_1z_v(void)
586{
587 return 0x00000047;
588}
589static inline u32 gmmu_pte_kind_z24s8_ms2_1z_v(void)
590{
591 return 0x00000048;
592}
593static inline u32 gmmu_pte_kind_z24s8_ms4_1z_v(void)
594{
595 return 0x00000049;
596}
597static inline u32 gmmu_pte_kind_z24s8_ms8_1z_v(void)
598{
599 return 0x0000004a;
600}
601static inline u32 gmmu_pte_kind_z24s8_ms16_1z_v(void)
602{
603 return 0x0000004b;
604}
605static inline u32 gmmu_pte_kind_z24s8_2cs_v(void)
606{
607 return 0x0000004c;
608}
609static inline u32 gmmu_pte_kind_z24s8_ms2_2cs_v(void)
610{
611 return 0x0000004d;
612}
613static inline u32 gmmu_pte_kind_z24s8_ms4_2cs_v(void)
614{
615 return 0x0000004e;
616}
617static inline u32 gmmu_pte_kind_z24s8_ms8_2cs_v(void)
618{
619 return 0x0000004f;
620}
621static inline u32 gmmu_pte_kind_z24s8_ms16_2cs_v(void)
622{
623 return 0x00000050;
624}
625static inline u32 gmmu_pte_kind_z24s8_2cz_v(void)
626{
627 return 0x00000051;
628}
629static inline u32 gmmu_pte_kind_z24s8_ms2_2cz_v(void)
630{
631 return 0x00000052;
632}
633static inline u32 gmmu_pte_kind_z24s8_ms4_2cz_v(void)
634{
635 return 0x00000053;
636}
637static inline u32 gmmu_pte_kind_z24s8_ms8_2cz_v(void)
638{
639 return 0x00000054;
640}
641static inline u32 gmmu_pte_kind_z24s8_ms16_2cz_v(void)
642{
643 return 0x00000055;
644}
645static inline u32 gmmu_pte_kind_z24s8_4cszv_v(void)
646{
647 return 0x00000056;
648}
649static inline u32 gmmu_pte_kind_z24s8_ms2_4cszv_v(void)
650{
651 return 0x00000057;
652}
653static inline u32 gmmu_pte_kind_z24s8_ms4_4cszv_v(void)
654{
655 return 0x00000058;
656}
657static inline u32 gmmu_pte_kind_z24s8_ms8_4cszv_v(void)
658{
659 return 0x00000059;
660}
661static inline u32 gmmu_pte_kind_z24s8_ms16_4cszv_v(void)
662{
663 return 0x0000005a;
664}
665static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_v(void)
666{
667 return 0x0000005b;
668}
669static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_v(void)
670{
671 return 0x0000005c;
672}
673static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_v(void)
674{
675 return 0x0000005d;
676}
677static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_v(void)
678{
679 return 0x0000005e;
680}
681static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_1zv_v(void)
682{
683 return 0x00000063;
684}
685static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_1zv_v(void)
686{
687 return 0x00000064;
688}
689static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_1zv_v(void)
690{
691 return 0x00000065;
692}
693static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_1zv_v(void)
694{
695 return 0x00000066;
696}
697static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_2cs_v(void)
698{
699 return 0x00000067;
700}
701static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_2cs_v(void)
702{
703 return 0x00000068;
704}
705static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_2cs_v(void)
706{
707 return 0x00000069;
708}
709static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_2cs_v(void)
710{
711 return 0x0000006a;
712}
713static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_2czv_v(void)
714{
715 return 0x0000006f;
716}
717static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_2czv_v(void)
718{
719 return 0x00000070;
720}
721static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_2czv_v(void)
722{
723 return 0x00000071;
724}
725static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_2czv_v(void)
726{
727 return 0x00000072;
728}
729static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_2zv_v(void)
730{
731 return 0x00000073;
732}
733static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_2zv_v(void)
734{
735 return 0x00000074;
736}
737static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_2zv_v(void)
738{
739 return 0x00000075;
740}
741static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_2zv_v(void)
742{
743 return 0x00000076;
744}
745static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_4cszv_v(void)
746{
747 return 0x00000077;
748}
749static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_4cszv_v(void)
750{
751 return 0x00000078;
752}
753static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_4cszv_v(void)
754{
755 return 0x00000079;
756}
757static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_4cszv_v(void)
758{
759 return 0x0000007a;
760}
761static inline u32 gmmu_pte_kind_zf32_v(void)
762{
763 return 0x0000007b;
764}
765static inline u32 gmmu_pte_kind_zf32_1z_v(void)
766{
767 return 0x0000007c;
768}
769static inline u32 gmmu_pte_kind_zf32_ms2_1z_v(void)
770{
771 return 0x0000007d;
772}
773static inline u32 gmmu_pte_kind_zf32_ms4_1z_v(void)
774{
775 return 0x0000007e;
776}
777static inline u32 gmmu_pte_kind_zf32_ms8_1z_v(void)
778{
779 return 0x0000007f;
780}
781static inline u32 gmmu_pte_kind_zf32_ms16_1z_v(void)
782{
783 return 0x00000080;
784}
785static inline u32 gmmu_pte_kind_zf32_2cs_v(void)
786{
787 return 0x00000081;
788}
789static inline u32 gmmu_pte_kind_zf32_ms2_2cs_v(void)
790{
791 return 0x00000082;
792}
793static inline u32 gmmu_pte_kind_zf32_ms4_2cs_v(void)
794{
795 return 0x00000083;
796}
797static inline u32 gmmu_pte_kind_zf32_ms8_2cs_v(void)
798{
799 return 0x00000084;
800}
801static inline u32 gmmu_pte_kind_zf32_ms16_2cs_v(void)
802{
803 return 0x00000085;
804}
805static inline u32 gmmu_pte_kind_zf32_2cz_v(void)
806{
807 return 0x00000086;
808}
809static inline u32 gmmu_pte_kind_zf32_ms2_2cz_v(void)
810{
811 return 0x00000087;
812}
813static inline u32 gmmu_pte_kind_zf32_ms4_2cz_v(void)
814{
815 return 0x00000088;
816}
817static inline u32 gmmu_pte_kind_zf32_ms8_2cz_v(void)
818{
819 return 0x00000089;
820}
821static inline u32 gmmu_pte_kind_zf32_ms16_2cz_v(void)
822{
823 return 0x0000008a;
824}
825static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_v(void)
826{
827 return 0x0000008b;
828}
829static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_v(void)
830{
831 return 0x0000008c;
832}
833static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_v(void)
834{
835 return 0x0000008d;
836}
837static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_v(void)
838{
839 return 0x0000008e;
840}
841static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_1cs_v(void)
842{
843 return 0x0000008f;
844}
845static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_1cs_v(void)
846{
847 return 0x00000090;
848}
849static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_1cs_v(void)
850{
851 return 0x00000091;
852}
853static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_1cs_v(void)
854{
855 return 0x00000092;
856}
857static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_1zv_v(void)
858{
859 return 0x00000097;
860}
861static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_1zv_v(void)
862{
863 return 0x00000098;
864}
865static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_1zv_v(void)
866{
867 return 0x00000099;
868}
869static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_1zv_v(void)
870{
871 return 0x0000009a;
872}
873static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_1czv_v(void)
874{
875 return 0x0000009b;
876}
877static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_1czv_v(void)
878{
879 return 0x0000009c;
880}
881static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_1czv_v(void)
882{
883 return 0x0000009d;
884}
885static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_1czv_v(void)
886{
887 return 0x0000009e;
888}
889static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_2cs_v(void)
890{
891 return 0x0000009f;
892}
893static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_2cs_v(void)
894{
895 return 0x000000a0;
896}
897static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_2cs_v(void)
898{
899 return 0x000000a1;
900}
901static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_2cs_v(void)
902{
903 return 0x000000a2;
904}
905static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_2cszv_v(void)
906{
907 return 0x000000a3;
908}
909static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_2cszv_v(void)
910{
911 return 0x000000a4;
912}
913static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_2cszv_v(void)
914{
915 return 0x000000a5;
916}
917static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_2cszv_v(void)
918{
919 return 0x000000a6;
920}
921static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_v(void)
922{
923 return 0x000000a7;
924}
925static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_v(void)
926{
927 return 0x000000a8;
928}
929static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_v(void)
930{
931 return 0x000000a9;
932}
933static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_v(void)
934{
935 return 0x000000aa;
936}
937static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_1cs_v(void)
938{
939 return 0x000000ab;
940}
941static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_1cs_v(void)
942{
943 return 0x000000ac;
944}
945static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_1cs_v(void)
946{
947 return 0x000000ad;
948}
949static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_1cs_v(void)
950{
951 return 0x000000ae;
952}
953static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_1zv_v(void)
954{
955 return 0x000000b3;
956}
957static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_1zv_v(void)
958{
959 return 0x000000b4;
960}
961static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_1zv_v(void)
962{
963 return 0x000000b5;
964}
965static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_1zv_v(void)
966{
967 return 0x000000b6;
968}
969static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_1czv_v(void)
970{
971 return 0x000000b7;
972}
973static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_1czv_v(void)
974{
975 return 0x000000b8;
976}
977static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_1czv_v(void)
978{
979 return 0x000000b9;
980}
981static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_1czv_v(void)
982{
983 return 0x000000ba;
984}
985static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_2cs_v(void)
986{
987 return 0x000000bb;
988}
989static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_2cs_v(void)
990{
991 return 0x000000bc;
992}
993static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_2cs_v(void)
994{
995 return 0x000000bd;
996}
997static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_2cs_v(void)
998{
999 return 0x000000be;
1000}
1001static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_2cszv_v(void)
1002{
1003 return 0x000000bf;
1004}
1005static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_2cszv_v(void)
1006{
1007 return 0x000000c0;
1008}
1009static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_2cszv_v(void)
1010{
1011 return 0x000000c1;
1012}
1013static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_2cszv_v(void)
1014{
1015 return 0x000000c2;
1016}
1017static inline u32 gmmu_pte_kind_zf32_x24s8_v(void)
1018{
1019 return 0x000000c3;
1020}
1021static inline u32 gmmu_pte_kind_zf32_x24s8_1cs_v(void)
1022{
1023 return 0x000000c4;
1024}
1025static inline u32 gmmu_pte_kind_zf32_x24s8_ms2_1cs_v(void)
1026{
1027 return 0x000000c5;
1028}
1029static inline u32 gmmu_pte_kind_zf32_x24s8_ms4_1cs_v(void)
1030{
1031 return 0x000000c6;
1032}
1033static inline u32 gmmu_pte_kind_zf32_x24s8_ms8_1cs_v(void)
1034{
1035 return 0x000000c7;
1036}
1037static inline u32 gmmu_pte_kind_zf32_x24s8_ms16_1cs_v(void)
1038{
1039 return 0x000000c8;
1040}
1041static inline u32 gmmu_pte_kind_zf32_x24s8_2cszv_v(void)
1042{
1043 return 0x000000ce;
1044}
1045static inline u32 gmmu_pte_kind_zf32_x24s8_ms2_2cszv_v(void)
1046{
1047 return 0x000000cf;
1048}
1049static inline u32 gmmu_pte_kind_zf32_x24s8_ms4_2cszv_v(void)
1050{
1051 return 0x000000d0;
1052}
1053static inline u32 gmmu_pte_kind_zf32_x24s8_ms8_2cszv_v(void)
1054{
1055 return 0x000000d1;
1056}
1057static inline u32 gmmu_pte_kind_zf32_x24s8_ms16_2cszv_v(void)
1058{
1059 return 0x000000d2;
1060}
1061static inline u32 gmmu_pte_kind_zf32_x24s8_2cs_v(void)
1062{
1063 return 0x000000d3;
1064}
1065static inline u32 gmmu_pte_kind_zf32_x24s8_ms2_2cs_v(void)
1066{
1067 return 0x000000d4;
1068}
1069static inline u32 gmmu_pte_kind_zf32_x24s8_ms4_2cs_v(void)
1070{
1071 return 0x000000d5;
1072}
1073static inline u32 gmmu_pte_kind_zf32_x24s8_ms8_2cs_v(void)
1074{
1075 return 0x000000d6;
1076}
1077static inline u32 gmmu_pte_kind_zf32_x24s8_ms16_2cs_v(void)
1078{
1079 return 0x000000d7;
1080}
1081static inline u32 gmmu_pte_kind_generic_16bx2_v(void)
1082{
1083 return 0x000000fe;
1084}
1085static inline u32 gmmu_pte_kind_c32_2c_v(void)
1086{
1087 return 0x000000d8;
1088}
1089static inline u32 gmmu_pte_kind_c32_2cbr_v(void)
1090{
1091 return 0x000000d9;
1092}
1093static inline u32 gmmu_pte_kind_c32_2cba_v(void)
1094{
1095 return 0x000000da;
1096}
1097static inline u32 gmmu_pte_kind_c32_2cra_v(void)
1098{
1099 return 0x000000db;
1100}
1101static inline u32 gmmu_pte_kind_c32_2bra_v(void)
1102{
1103 return 0x000000dc;
1104}
1105static inline u32 gmmu_pte_kind_c32_ms2_2c_v(void)
1106{
1107 return 0x000000dd;
1108}
1109static inline u32 gmmu_pte_kind_c32_ms2_2cbr_v(void)
1110{
1111 return 0x000000de;
1112}
1113static inline u32 gmmu_pte_kind_c32_ms4_2c_v(void)
1114{
1115 return 0x000000df;
1116}
1117static inline u32 gmmu_pte_kind_c32_ms4_2cbr_v(void)
1118{
1119 return 0x000000e0;
1120}
1121static inline u32 gmmu_pte_kind_c32_ms4_2cba_v(void)
1122{
1123 return 0x000000e1;
1124}
1125static inline u32 gmmu_pte_kind_c32_ms4_2cra_v(void)
1126{
1127 return 0x000000e2;
1128}
1129static inline u32 gmmu_pte_kind_c32_ms4_2bra_v(void)
1130{
1131 return 0x000000e3;
1132}
1133static inline u32 gmmu_pte_kind_c32_ms4_4cbra_v(void)
1134{
1135 return 0x0000002c;
1136}
1137static inline u32 gmmu_pte_kind_c32_ms8_ms16_2c_v(void)
1138{
1139 return 0x000000e4;
1140}
1141static inline u32 gmmu_pte_kind_c32_ms8_ms16_2cra_v(void)
1142{
1143 return 0x000000e5;
1144}
1145static inline u32 gmmu_pte_kind_c64_2c_v(void)
1146{
1147 return 0x000000e6;
1148}
1149static inline u32 gmmu_pte_kind_c64_2cbr_v(void)
1150{
1151 return 0x000000e7;
1152}
1153static inline u32 gmmu_pte_kind_c64_2cba_v(void)
1154{
1155 return 0x000000e8;
1156}
1157static inline u32 gmmu_pte_kind_c64_2cra_v(void)
1158{
1159 return 0x000000e9;
1160}
1161static inline u32 gmmu_pte_kind_c64_2bra_v(void)
1162{
1163 return 0x000000ea;
1164}
1165static inline u32 gmmu_pte_kind_c64_ms2_2c_v(void)
1166{
1167 return 0x000000eb;
1168}
1169static inline u32 gmmu_pte_kind_c64_ms2_2cbr_v(void)
1170{
1171 return 0x000000ec;
1172}
1173static inline u32 gmmu_pte_kind_c64_ms4_2c_v(void)
1174{
1175 return 0x000000ed;
1176}
1177static inline u32 gmmu_pte_kind_c64_ms4_2cbr_v(void)
1178{
1179 return 0x000000ee;
1180}
1181static inline u32 gmmu_pte_kind_c64_ms4_2cba_v(void)
1182{
1183 return 0x000000ef;
1184}
1185static inline u32 gmmu_pte_kind_c64_ms4_2cra_v(void)
1186{
1187 return 0x000000f0;
1188}
1189static inline u32 gmmu_pte_kind_c64_ms4_2bra_v(void)
1190{
1191 return 0x000000f1;
1192}
1193static inline u32 gmmu_pte_kind_c64_ms4_4cbra_v(void)
1194{
1195 return 0x0000002d;
1196}
1197static inline u32 gmmu_pte_kind_c64_ms8_ms16_2c_v(void)
1198{
1199 return 0x000000f2;
1200}
1201static inline u32 gmmu_pte_kind_c64_ms8_ms16_2cra_v(void)
1202{
1203 return 0x000000f3;
1204}
1205static inline u32 gmmu_pte_kind_c128_2c_v(void)
1206{
1207 return 0x000000f4;
1208}
1209static inline u32 gmmu_pte_kind_c128_2cr_v(void)
1210{
1211 return 0x000000f5;
1212}
1213static inline u32 gmmu_pte_kind_c128_ms2_2c_v(void)
1214{
1215 return 0x000000f6;
1216}
1217static inline u32 gmmu_pte_kind_c128_ms2_2cr_v(void)
1218{
1219 return 0x000000f7;
1220}
1221static inline u32 gmmu_pte_kind_c128_ms4_2c_v(void)
1222{
1223 return 0x000000f8;
1224}
1225static inline u32 gmmu_pte_kind_c128_ms4_2cr_v(void)
1226{
1227 return 0x000000f9;
1228}
1229static inline u32 gmmu_pte_kind_c128_ms8_ms16_2c_v(void)
1230{
1231 return 0x000000fa;
1232}
1233static inline u32 gmmu_pte_kind_c128_ms8_ms16_2cr_v(void)
1234{
1235 return 0x000000fb;
1236}
1237static inline u32 gmmu_pte_kind_x8c24_v(void)
1238{
1239 return 0x000000fc;
1240}
1241static inline u32 gmmu_pte_kind_pitch_no_swizzle_v(void)
1242{
1243 return 0x000000fd;
1244}
1245static inline u32 gmmu_pte_kind_smsked_message_v(void)
1246{
1247 return 0x000000ca;
1248}
1249static inline u32 gmmu_pte_kind_smhost_message_v(void)
1250{
1251 return 0x000000cb;
1252}
1253static inline u32 gmmu_pte_kind_s8_v(void)
1254{
1255 return 0x0000002a;
1256}
1257static inline u32 gmmu_pte_kind_s8_2s_v(void)
1258{
1259 return 0x0000002b;
1260}
1261#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_gr_gp106.h b/drivers/gpu/nvgpu/gp106/hw_gr_gp106.h
new file mode 100644
index 00000000..bb1f9fa9
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_gr_gp106.h
@@ -0,0 +1,4017 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_gr_gp106_h_
51#define _hw_gr_gp106_h_
52
53static inline u32 gr_intr_r(void)
54{
55 return 0x00400100;
56}
57static inline u32 gr_intr_notify_pending_f(void)
58{
59 return 0x1;
60}
61static inline u32 gr_intr_notify_reset_f(void)
62{
63 return 0x1;
64}
65static inline u32 gr_intr_semaphore_pending_f(void)
66{
67 return 0x2;
68}
69static inline u32 gr_intr_semaphore_reset_f(void)
70{
71 return 0x2;
72}
73static inline u32 gr_intr_illegal_method_pending_f(void)
74{
75 return 0x10;
76}
77static inline u32 gr_intr_illegal_method_reset_f(void)
78{
79 return 0x10;
80}
81static inline u32 gr_intr_illegal_notify_pending_f(void)
82{
83 return 0x40;
84}
85static inline u32 gr_intr_illegal_notify_reset_f(void)
86{
87 return 0x40;
88}
89static inline u32 gr_intr_firmware_method_f(u32 v)
90{
91 return (v & 0x1) << 8;
92}
93static inline u32 gr_intr_firmware_method_pending_f(void)
94{
95 return 0x100;
96}
97static inline u32 gr_intr_firmware_method_reset_f(void)
98{
99 return 0x100;
100}
101static inline u32 gr_intr_illegal_class_pending_f(void)
102{
103 return 0x20;
104}
105static inline u32 gr_intr_illegal_class_reset_f(void)
106{
107 return 0x20;
108}
109static inline u32 gr_intr_fecs_error_pending_f(void)
110{
111 return 0x80000;
112}
113static inline u32 gr_intr_fecs_error_reset_f(void)
114{
115 return 0x80000;
116}
117static inline u32 gr_intr_class_error_pending_f(void)
118{
119 return 0x100000;
120}
121static inline u32 gr_intr_class_error_reset_f(void)
122{
123 return 0x100000;
124}
125static inline u32 gr_intr_exception_pending_f(void)
126{
127 return 0x200000;
128}
129static inline u32 gr_intr_exception_reset_f(void)
130{
131 return 0x200000;
132}
133static inline u32 gr_fecs_intr_r(void)
134{
135 return 0x00400144;
136}
137static inline u32 gr_class_error_r(void)
138{
139 return 0x00400110;
140}
141static inline u32 gr_class_error_code_v(u32 r)
142{
143 return (r >> 0) & 0xffff;
144}
145static inline u32 gr_intr_nonstall_r(void)
146{
147 return 0x00400120;
148}
149static inline u32 gr_intr_nonstall_trap_pending_f(void)
150{
151 return 0x2;
152}
153static inline u32 gr_intr_en_r(void)
154{
155 return 0x0040013c;
156}
157static inline u32 gr_exception_r(void)
158{
159 return 0x00400108;
160}
161static inline u32 gr_exception_fe_m(void)
162{
163 return 0x1 << 0;
164}
165static inline u32 gr_exception_gpc_m(void)
166{
167 return 0x1 << 24;
168}
169static inline u32 gr_exception_memfmt_m(void)
170{
171 return 0x1 << 1;
172}
173static inline u32 gr_exception_ds_m(void)
174{
175 return 0x1 << 4;
176}
177static inline u32 gr_exception1_r(void)
178{
179 return 0x00400118;
180}
181static inline u32 gr_exception1_gpc_0_pending_f(void)
182{
183 return 0x1;
184}
185static inline u32 gr_exception2_r(void)
186{
187 return 0x0040011c;
188}
189static inline u32 gr_exception_en_r(void)
190{
191 return 0x00400138;
192}
193static inline u32 gr_exception_en_fe_m(void)
194{
195 return 0x1 << 0;
196}
197static inline u32 gr_exception1_en_r(void)
198{
199 return 0x00400130;
200}
201static inline u32 gr_exception2_en_r(void)
202{
203 return 0x00400134;
204}
205static inline u32 gr_gpfifo_ctl_r(void)
206{
207 return 0x00400500;
208}
209static inline u32 gr_gpfifo_ctl_access_f(u32 v)
210{
211 return (v & 0x1) << 0;
212}
213static inline u32 gr_gpfifo_ctl_access_disabled_f(void)
214{
215 return 0x0;
216}
217static inline u32 gr_gpfifo_ctl_access_enabled_f(void)
218{
219 return 0x1;
220}
221static inline u32 gr_gpfifo_ctl_semaphore_access_f(u32 v)
222{
223 return (v & 0x1) << 16;
224}
225static inline u32 gr_gpfifo_ctl_semaphore_access_enabled_v(void)
226{
227 return 0x00000001;
228}
229static inline u32 gr_gpfifo_ctl_semaphore_access_enabled_f(void)
230{
231 return 0x10000;
232}
233static inline u32 gr_gpfifo_status_r(void)
234{
235 return 0x00400504;
236}
237static inline u32 gr_trapped_addr_r(void)
238{
239 return 0x00400704;
240}
241static inline u32 gr_trapped_addr_mthd_v(u32 r)
242{
243 return (r >> 2) & 0xfff;
244}
245static inline u32 gr_trapped_addr_subch_v(u32 r)
246{
247 return (r >> 16) & 0x7;
248}
249static inline u32 gr_trapped_data_lo_r(void)
250{
251 return 0x00400708;
252}
253static inline u32 gr_trapped_data_hi_r(void)
254{
255 return 0x0040070c;
256}
257static inline u32 gr_status_r(void)
258{
259 return 0x00400700;
260}
261static inline u32 gr_status_fe_method_upper_v(u32 r)
262{
263 return (r >> 1) & 0x1;
264}
265static inline u32 gr_status_fe_method_lower_v(u32 r)
266{
267 return (r >> 2) & 0x1;
268}
269static inline u32 gr_status_fe_method_lower_idle_v(void)
270{
271 return 0x00000000;
272}
273static inline u32 gr_status_fe_gi_v(u32 r)
274{
275 return (r >> 21) & 0x1;
276}
277static inline u32 gr_status_mask_r(void)
278{
279 return 0x00400610;
280}
281static inline u32 gr_status_1_r(void)
282{
283 return 0x00400604;
284}
285static inline u32 gr_status_2_r(void)
286{
287 return 0x00400608;
288}
289static inline u32 gr_engine_status_r(void)
290{
291 return 0x0040060c;
292}
293static inline u32 gr_engine_status_value_busy_f(void)
294{
295 return 0x1;
296}
297static inline u32 gr_pri_be0_becs_be_exception_r(void)
298{
299 return 0x00410204;
300}
301static inline u32 gr_pri_be0_becs_be_exception_en_r(void)
302{
303 return 0x00410208;
304}
305static inline u32 gr_pri_gpc0_gpccs_gpc_exception_r(void)
306{
307 return 0x00502c90;
308}
309static inline u32 gr_pri_gpc0_gpccs_gpc_exception_en_r(void)
310{
311 return 0x00502c94;
312}
313static inline u32 gr_pri_gpc0_tpc0_tpccs_tpc_exception_r(void)
314{
315 return 0x00504508;
316}
317static inline u32 gr_pri_gpc0_tpc0_tpccs_tpc_exception_en_r(void)
318{
319 return 0x0050450c;
320}
321static inline u32 gr_activity_0_r(void)
322{
323 return 0x00400380;
324}
325static inline u32 gr_activity_1_r(void)
326{
327 return 0x00400384;
328}
329static inline u32 gr_activity_2_r(void)
330{
331 return 0x00400388;
332}
333static inline u32 gr_activity_4_r(void)
334{
335 return 0x00400390;
336}
337static inline u32 gr_activity_4_gpc0_s(void)
338{
339 return 3;
340}
341static inline u32 gr_activity_4_gpc0_f(u32 v)
342{
343 return (v & 0x7) << 0;
344}
345static inline u32 gr_activity_4_gpc0_m(void)
346{
347 return 0x7 << 0;
348}
349static inline u32 gr_activity_4_gpc0_v(u32 r)
350{
351 return (r >> 0) & 0x7;
352}
353static inline u32 gr_activity_4_gpc0_empty_v(void)
354{
355 return 0x00000000;
356}
357static inline u32 gr_activity_4_gpc0_preempted_v(void)
358{
359 return 0x00000004;
360}
361static inline u32 gr_pri_gpc0_gcc_dbg_r(void)
362{
363 return 0x00501000;
364}
365static inline u32 gr_pri_gpcs_gcc_dbg_r(void)
366{
367 return 0x00419000;
368}
369static inline u32 gr_pri_gpcs_gcc_dbg_invalidate_m(void)
370{
371 return 0x1 << 1;
372}
373static inline u32 gr_pri_gpc0_tpc0_sm_cache_control_r(void)
374{
375 return 0x005046a4;
376}
377static inline u32 gr_pri_gpcs_tpcs_sm_cache_control_r(void)
378{
379 return 0x00419ea4;
380}
381static inline u32 gr_pri_gpcs_tpcs_sm_cache_control_invalidate_cache_m(void)
382{
383 return 0x1 << 0;
384}
385static inline u32 gr_pri_sked_activity_r(void)
386{
387 return 0x00407054;
388}
389static inline u32 gr_pri_gpc0_gpccs_gpc_activity0_r(void)
390{
391 return 0x00502c80;
392}
393static inline u32 gr_pri_gpc0_gpccs_gpc_activity1_r(void)
394{
395 return 0x00502c84;
396}
397static inline u32 gr_pri_gpc0_gpccs_gpc_activity2_r(void)
398{
399 return 0x00502c88;
400}
401static inline u32 gr_pri_gpc0_gpccs_gpc_activity3_r(void)
402{
403 return 0x00502c8c;
404}
405static inline u32 gr_pri_gpc0_tpc0_tpccs_tpc_activity_0_r(void)
406{
407 return 0x00504500;
408}
409static inline u32 gr_pri_gpc0_tpc1_tpccs_tpc_activity_0_r(void)
410{
411 return 0x00504d00;
412}
413static inline u32 gr_pri_gpc0_tpcs_tpccs_tpc_activity_0_r(void)
414{
415 return 0x00501d00;
416}
417static inline u32 gr_pri_gpcs_gpccs_gpc_activity_0_r(void)
418{
419 return 0x0041ac80;
420}
421static inline u32 gr_pri_gpcs_gpccs_gpc_activity_1_r(void)
422{
423 return 0x0041ac84;
424}
425static inline u32 gr_pri_gpcs_gpccs_gpc_activity_2_r(void)
426{
427 return 0x0041ac88;
428}
429static inline u32 gr_pri_gpcs_gpccs_gpc_activity_3_r(void)
430{
431 return 0x0041ac8c;
432}
433static inline u32 gr_pri_gpcs_tpc0_tpccs_tpc_activity_0_r(void)
434{
435 return 0x0041c500;
436}
437static inline u32 gr_pri_gpcs_tpc1_tpccs_tpc_activity_0_r(void)
438{
439 return 0x0041cd00;
440}
441static inline u32 gr_pri_gpcs_tpcs_tpccs_tpc_activity_0_r(void)
442{
443 return 0x00419d00;
444}
445static inline u32 gr_pri_be0_becs_be_activity0_r(void)
446{
447 return 0x00410200;
448}
449static inline u32 gr_pri_be1_becs_be_activity0_r(void)
450{
451 return 0x00410600;
452}
453static inline u32 gr_pri_bes_becs_be_activity0_r(void)
454{
455 return 0x00408a00;
456}
457static inline u32 gr_pri_ds_mpipe_status_r(void)
458{
459 return 0x00405858;
460}
461static inline u32 gr_pri_fe_go_idle_info_r(void)
462{
463 return 0x00404194;
464}
465static inline u32 gr_pri_gpc0_tpc0_tex_m_tex_subunits_status_r(void)
466{
467 return 0x00504238;
468}
469static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_r(void)
470{
471 return 0x005046b8;
472}
473static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp0_pending_f(void)
474{
475 return 0x10;
476}
477static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp1_pending_f(void)
478{
479 return 0x20;
480}
481static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp2_pending_f(void)
482{
483 return 0x40;
484}
485static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp3_pending_f(void)
486{
487 return 0x80;
488}
489static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp0_pending_f(void)
490{
491 return 0x100;
492}
493static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp1_pending_f(void)
494{
495 return 0x200;
496}
497static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp2_pending_f(void)
498{
499 return 0x400;
500}
501static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp3_pending_f(void)
502{
503 return 0x800;
504}
505static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_r(void)
506{
507 return 0x005044a0;
508}
509static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_corrected_shm0_pending_f(void)
510{
511 return 0x1;
512}
513static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_corrected_shm1_pending_f(void)
514{
515 return 0x2;
516}
517static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_detected_shm0_pending_f(void)
518{
519 return 0x10;
520}
521static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_detected_shm1_pending_f(void)
522{
523 return 0x20;
524}
525static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_double_err_detected_shm0_pending_f(void)
526{
527 return 0x100;
528}
529static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_double_err_detected_shm1_pending_f(void)
530{
531 return 0x200;
532}
533static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_single_err_count_r(void)
534{
535 return 0x005046bc;
536}
537static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_double_err_count_r(void)
538{
539 return 0x005046c0;
540}
541static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_r(void)
542{
543 return 0x005044a4;
544}
545static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_corrected_m(void)
546{
547 return 0xff << 0;
548}
549static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_corrected_v(u32 r)
550{
551 return (r >> 0) & 0xff;
552}
553static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_detected_m(void)
554{
555 return 0xff << 8;
556}
557static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_detected_v(u32 r)
558{
559 return (r >> 8) & 0xff;
560}
561static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_double_detected_m(void)
562{
563 return 0xff << 16;
564}
565static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_double_detected_v(u32 r)
566{
567 return (r >> 16) & 0xff;
568}
569static inline u32 gr_pri_gpc0_tpc0_tex_m_routing_r(void)
570{
571 return 0x005042c4;
572}
573static inline u32 gr_pri_gpc0_tpc0_tex_m_routing_sel_default_f(void)
574{
575 return 0x0;
576}
577static inline u32 gr_pri_gpc0_tpc0_tex_m_routing_sel_pipe0_f(void)
578{
579 return 0x1;
580}
581static inline u32 gr_pri_gpc0_tpc0_tex_m_routing_sel_pipe1_f(void)
582{
583 return 0x2;
584}
585static inline u32 gr_pri_be0_crop_status1_r(void)
586{
587 return 0x00410134;
588}
589static inline u32 gr_pri_bes_crop_status1_r(void)
590{
591 return 0x00408934;
592}
593static inline u32 gr_pri_be0_zrop_status_r(void)
594{
595 return 0x00410048;
596}
597static inline u32 gr_pri_be0_zrop_status2_r(void)
598{
599 return 0x0041004c;
600}
601static inline u32 gr_pri_bes_zrop_status_r(void)
602{
603 return 0x00408848;
604}
605static inline u32 gr_pri_bes_zrop_status2_r(void)
606{
607 return 0x0040884c;
608}
609static inline u32 gr_pipe_bundle_address_r(void)
610{
611 return 0x00400200;
612}
613static inline u32 gr_pipe_bundle_address_value_v(u32 r)
614{
615 return (r >> 0) & 0xffff;
616}
617static inline u32 gr_pipe_bundle_data_r(void)
618{
619 return 0x00400204;
620}
621static inline u32 gr_pipe_bundle_config_r(void)
622{
623 return 0x00400208;
624}
625static inline u32 gr_pipe_bundle_config_override_pipe_mode_disabled_f(void)
626{
627 return 0x0;
628}
629static inline u32 gr_pipe_bundle_config_override_pipe_mode_enabled_f(void)
630{
631 return 0x80000000;
632}
633static inline u32 gr_fe_hww_esr_r(void)
634{
635 return 0x00404000;
636}
637static inline u32 gr_fe_hww_esr_reset_active_f(void)
638{
639 return 0x40000000;
640}
641static inline u32 gr_fe_hww_esr_en_enable_f(void)
642{
643 return 0x80000000;
644}
645static inline u32 gr_fe_go_idle_timeout_r(void)
646{
647 return 0x00404154;
648}
649static inline u32 gr_fe_go_idle_timeout_count_f(u32 v)
650{
651 return (v & 0xffffffff) << 0;
652}
653static inline u32 gr_fe_go_idle_timeout_count_disabled_f(void)
654{
655 return 0x0;
656}
657static inline u32 gr_fe_go_idle_timeout_count_prod_f(void)
658{
659 return 0x1800;
660}
661static inline u32 gr_fe_object_table_r(u32 i)
662{
663 return 0x00404200 + i*4;
664}
665static inline u32 gr_fe_object_table_nvclass_v(u32 r)
666{
667 return (r >> 0) & 0xffff;
668}
669static inline u32 gr_fe_tpc_fs_r(void)
670{
671 return 0x004041c4;
672}
673static inline u32 gr_pri_mme_shadow_raw_index_r(void)
674{
675 return 0x00404488;
676}
677static inline u32 gr_pri_mme_shadow_raw_index_write_trigger_f(void)
678{
679 return 0x80000000;
680}
681static inline u32 gr_pri_mme_shadow_raw_data_r(void)
682{
683 return 0x0040448c;
684}
685static inline u32 gr_mme_hww_esr_r(void)
686{
687 return 0x00404490;
688}
689static inline u32 gr_mme_hww_esr_reset_active_f(void)
690{
691 return 0x40000000;
692}
693static inline u32 gr_mme_hww_esr_en_enable_f(void)
694{
695 return 0x80000000;
696}
697static inline u32 gr_memfmt_hww_esr_r(void)
698{
699 return 0x00404600;
700}
701static inline u32 gr_memfmt_hww_esr_reset_active_f(void)
702{
703 return 0x40000000;
704}
705static inline u32 gr_memfmt_hww_esr_en_enable_f(void)
706{
707 return 0x80000000;
708}
709static inline u32 gr_fecs_cpuctl_r(void)
710{
711 return 0x00409100;
712}
713static inline u32 gr_fecs_cpuctl_startcpu_f(u32 v)
714{
715 return (v & 0x1) << 1;
716}
717static inline u32 gr_fecs_cpuctl_alias_r(void)
718{
719 return 0x00409130;
720}
721static inline u32 gr_fecs_cpuctl_alias_startcpu_f(u32 v)
722{
723 return (v & 0x1) << 1;
724}
725static inline u32 gr_fecs_dmactl_r(void)
726{
727 return 0x0040910c;
728}
729static inline u32 gr_fecs_dmactl_require_ctx_f(u32 v)
730{
731 return (v & 0x1) << 0;
732}
733static inline u32 gr_fecs_dmactl_dmem_scrubbing_m(void)
734{
735 return 0x1 << 1;
736}
737static inline u32 gr_fecs_dmactl_imem_scrubbing_m(void)
738{
739 return 0x1 << 2;
740}
741static inline u32 gr_fecs_os_r(void)
742{
743 return 0x00409080;
744}
745static inline u32 gr_fecs_idlestate_r(void)
746{
747 return 0x0040904c;
748}
749static inline u32 gr_fecs_mailbox0_r(void)
750{
751 return 0x00409040;
752}
753static inline u32 gr_fecs_mailbox1_r(void)
754{
755 return 0x00409044;
756}
757static inline u32 gr_fecs_irqstat_r(void)
758{
759 return 0x00409008;
760}
761static inline u32 gr_fecs_irqmode_r(void)
762{
763 return 0x0040900c;
764}
765static inline u32 gr_fecs_irqmask_r(void)
766{
767 return 0x00409018;
768}
769static inline u32 gr_fecs_irqdest_r(void)
770{
771 return 0x0040901c;
772}
773static inline u32 gr_fecs_curctx_r(void)
774{
775 return 0x00409050;
776}
777static inline u32 gr_fecs_nxtctx_r(void)
778{
779 return 0x00409054;
780}
781static inline u32 gr_fecs_engctl_r(void)
782{
783 return 0x004090a4;
784}
785static inline u32 gr_fecs_debug1_r(void)
786{
787 return 0x00409090;
788}
789static inline u32 gr_fecs_debuginfo_r(void)
790{
791 return 0x00409094;
792}
793static inline u32 gr_fecs_icd_cmd_r(void)
794{
795 return 0x00409200;
796}
797static inline u32 gr_fecs_icd_cmd_opc_s(void)
798{
799 return 4;
800}
801static inline u32 gr_fecs_icd_cmd_opc_f(u32 v)
802{
803 return (v & 0xf) << 0;
804}
805static inline u32 gr_fecs_icd_cmd_opc_m(void)
806{
807 return 0xf << 0;
808}
809static inline u32 gr_fecs_icd_cmd_opc_v(u32 r)
810{
811 return (r >> 0) & 0xf;
812}
813static inline u32 gr_fecs_icd_cmd_opc_rreg_f(void)
814{
815 return 0x8;
816}
817static inline u32 gr_fecs_icd_cmd_opc_rstat_f(void)
818{
819 return 0xe;
820}
821static inline u32 gr_fecs_icd_cmd_idx_f(u32 v)
822{
823 return (v & 0x1f) << 8;
824}
825static inline u32 gr_fecs_icd_rdata_r(void)
826{
827 return 0x0040920c;
828}
829static inline u32 gr_fecs_imemc_r(u32 i)
830{
831 return 0x00409180 + i*16;
832}
833static inline u32 gr_fecs_imemc_offs_f(u32 v)
834{
835 return (v & 0x3f) << 2;
836}
837static inline u32 gr_fecs_imemc_blk_f(u32 v)
838{
839 return (v & 0xff) << 8;
840}
841static inline u32 gr_fecs_imemc_aincw_f(u32 v)
842{
843 return (v & 0x1) << 24;
844}
845static inline u32 gr_fecs_imemd_r(u32 i)
846{
847 return 0x00409184 + i*16;
848}
849static inline u32 gr_fecs_imemt_r(u32 i)
850{
851 return 0x00409188 + i*16;
852}
853static inline u32 gr_fecs_imemt_tag_f(u32 v)
854{
855 return (v & 0xffff) << 0;
856}
857static inline u32 gr_fecs_dmemc_r(u32 i)
858{
859 return 0x004091c0 + i*8;
860}
861static inline u32 gr_fecs_dmemc_offs_s(void)
862{
863 return 6;
864}
865static inline u32 gr_fecs_dmemc_offs_f(u32 v)
866{
867 return (v & 0x3f) << 2;
868}
869static inline u32 gr_fecs_dmemc_offs_m(void)
870{
871 return 0x3f << 2;
872}
873static inline u32 gr_fecs_dmemc_offs_v(u32 r)
874{
875 return (r >> 2) & 0x3f;
876}
877static inline u32 gr_fecs_dmemc_blk_f(u32 v)
878{
879 return (v & 0xff) << 8;
880}
881static inline u32 gr_fecs_dmemc_aincw_f(u32 v)
882{
883 return (v & 0x1) << 24;
884}
885static inline u32 gr_fecs_dmemd_r(u32 i)
886{
887 return 0x004091c4 + i*8;
888}
889static inline u32 gr_fecs_dmatrfbase_r(void)
890{
891 return 0x00409110;
892}
893static inline u32 gr_fecs_dmatrfmoffs_r(void)
894{
895 return 0x00409114;
896}
897static inline u32 gr_fecs_dmatrffboffs_r(void)
898{
899 return 0x0040911c;
900}
901static inline u32 gr_fecs_dmatrfcmd_r(void)
902{
903 return 0x00409118;
904}
905static inline u32 gr_fecs_dmatrfcmd_imem_f(u32 v)
906{
907 return (v & 0x1) << 4;
908}
909static inline u32 gr_fecs_dmatrfcmd_write_f(u32 v)
910{
911 return (v & 0x1) << 5;
912}
913static inline u32 gr_fecs_dmatrfcmd_size_f(u32 v)
914{
915 return (v & 0x7) << 8;
916}
917static inline u32 gr_fecs_dmatrfcmd_ctxdma_f(u32 v)
918{
919 return (v & 0x7) << 12;
920}
921static inline u32 gr_fecs_bootvec_r(void)
922{
923 return 0x00409104;
924}
925static inline u32 gr_fecs_bootvec_vec_f(u32 v)
926{
927 return (v & 0xffffffff) << 0;
928}
929static inline u32 gr_fecs_falcon_hwcfg_r(void)
930{
931 return 0x00409108;
932}
933static inline u32 gr_gpcs_gpccs_falcon_hwcfg_r(void)
934{
935 return 0x0041a108;
936}
937static inline u32 gr_fecs_falcon_rm_r(void)
938{
939 return 0x00409084;
940}
941static inline u32 gr_fecs_current_ctx_r(void)
942{
943 return 0x00409b00;
944}
945static inline u32 gr_fecs_current_ctx_ptr_f(u32 v)
946{
947 return (v & 0xfffffff) << 0;
948}
949static inline u32 gr_fecs_current_ctx_ptr_v(u32 r)
950{
951 return (r >> 0) & 0xfffffff;
952}
953static inline u32 gr_fecs_current_ctx_target_s(void)
954{
955 return 2;
956}
957static inline u32 gr_fecs_current_ctx_target_f(u32 v)
958{
959 return (v & 0x3) << 28;
960}
961static inline u32 gr_fecs_current_ctx_target_m(void)
962{
963 return 0x3 << 28;
964}
965static inline u32 gr_fecs_current_ctx_target_v(u32 r)
966{
967 return (r >> 28) & 0x3;
968}
969static inline u32 gr_fecs_current_ctx_target_vid_mem_f(void)
970{
971 return 0x0;
972}
973static inline u32 gr_fecs_current_ctx_target_sys_mem_coh_f(void)
974{
975 return 0x20000000;
976}
977static inline u32 gr_fecs_current_ctx_target_sys_mem_ncoh_f(void)
978{
979 return 0x30000000;
980}
981static inline u32 gr_fecs_current_ctx_valid_s(void)
982{
983 return 1;
984}
985static inline u32 gr_fecs_current_ctx_valid_f(u32 v)
986{
987 return (v & 0x1) << 31;
988}
989static inline u32 gr_fecs_current_ctx_valid_m(void)
990{
991 return 0x1 << 31;
992}
993static inline u32 gr_fecs_current_ctx_valid_v(u32 r)
994{
995 return (r >> 31) & 0x1;
996}
997static inline u32 gr_fecs_current_ctx_valid_false_f(void)
998{
999 return 0x0;
1000}
1001static inline u32 gr_fecs_method_data_r(void)
1002{
1003 return 0x00409500;
1004}
1005static inline u32 gr_fecs_method_push_r(void)
1006{
1007 return 0x00409504;
1008}
1009static inline u32 gr_fecs_method_push_adr_f(u32 v)
1010{
1011 return (v & 0xfff) << 0;
1012}
1013static inline u32 gr_fecs_method_push_adr_bind_pointer_v(void)
1014{
1015 return 0x00000003;
1016}
1017static inline u32 gr_fecs_method_push_adr_bind_pointer_f(void)
1018{
1019 return 0x3;
1020}
1021static inline u32 gr_fecs_method_push_adr_discover_image_size_v(void)
1022{
1023 return 0x00000010;
1024}
1025static inline u32 gr_fecs_method_push_adr_wfi_golden_save_v(void)
1026{
1027 return 0x00000009;
1028}
1029static inline u32 gr_fecs_method_push_adr_restore_golden_v(void)
1030{
1031 return 0x00000015;
1032}
1033static inline u32 gr_fecs_method_push_adr_discover_zcull_image_size_v(void)
1034{
1035 return 0x00000016;
1036}
1037static inline u32 gr_fecs_method_push_adr_discover_pm_image_size_v(void)
1038{
1039 return 0x00000025;
1040}
1041static inline u32 gr_fecs_method_push_adr_discover_reglist_image_size_v(void)
1042{
1043 return 0x00000030;
1044}
1045static inline u32 gr_fecs_method_push_adr_set_reglist_bind_instance_v(void)
1046{
1047 return 0x00000031;
1048}
1049static inline u32 gr_fecs_method_push_adr_set_reglist_virtual_address_v(void)
1050{
1051 return 0x00000032;
1052}
1053static inline u32 gr_fecs_method_push_adr_stop_ctxsw_v(void)
1054{
1055 return 0x00000038;
1056}
1057static inline u32 gr_fecs_method_push_adr_start_ctxsw_v(void)
1058{
1059 return 0x00000039;
1060}
1061static inline u32 gr_fecs_method_push_adr_set_watchdog_timeout_f(void)
1062{
1063 return 0x21;
1064}
1065static inline u32 gr_fecs_method_push_adr_discover_preemption_image_size_v(void)
1066{
1067 return 0x0000001a;
1068}
1069static inline u32 gr_fecs_method_push_adr_halt_pipeline_v(void)
1070{
1071 return 0x00000004;
1072}
1073static inline u32 gr_fecs_host_int_status_r(void)
1074{
1075 return 0x00409c18;
1076}
1077static inline u32 gr_fecs_host_int_status_fault_during_ctxsw_f(u32 v)
1078{
1079 return (v & 0x1) << 16;
1080}
1081static inline u32 gr_fecs_host_int_status_umimp_firmware_method_f(u32 v)
1082{
1083 return (v & 0x1) << 17;
1084}
1085static inline u32 gr_fecs_host_int_status_umimp_illegal_method_f(u32 v)
1086{
1087 return (v & 0x1) << 18;
1088}
1089static inline u32 gr_fecs_host_int_clear_r(void)
1090{
1091 return 0x00409c20;
1092}
1093static inline u32 gr_fecs_host_int_enable_r(void)
1094{
1095 return 0x00409c24;
1096}
1097static inline u32 gr_fecs_host_int_enable_fault_during_ctxsw_enable_f(void)
1098{
1099 return 0x10000;
1100}
1101static inline u32 gr_fecs_host_int_enable_umimp_firmware_method_enable_f(void)
1102{
1103 return 0x20000;
1104}
1105static inline u32 gr_fecs_host_int_enable_umimp_illegal_method_enable_f(void)
1106{
1107 return 0x40000;
1108}
1109static inline u32 gr_fecs_host_int_enable_watchdog_enable_f(void)
1110{
1111 return 0x80000;
1112}
1113static inline u32 gr_fecs_ctxsw_reset_ctl_r(void)
1114{
1115 return 0x00409614;
1116}
1117static inline u32 gr_fecs_ctxsw_reset_ctl_sys_halt_disabled_f(void)
1118{
1119 return 0x0;
1120}
1121static inline u32 gr_fecs_ctxsw_reset_ctl_gpc_halt_disabled_f(void)
1122{
1123 return 0x0;
1124}
1125static inline u32 gr_fecs_ctxsw_reset_ctl_be_halt_disabled_f(void)
1126{
1127 return 0x0;
1128}
1129static inline u32 gr_fecs_ctxsw_reset_ctl_sys_engine_reset_disabled_f(void)
1130{
1131 return 0x10;
1132}
1133static inline u32 gr_fecs_ctxsw_reset_ctl_gpc_engine_reset_disabled_f(void)
1134{
1135 return 0x20;
1136}
1137static inline u32 gr_fecs_ctxsw_reset_ctl_be_engine_reset_disabled_f(void)
1138{
1139 return 0x40;
1140}
1141static inline u32 gr_fecs_ctxsw_reset_ctl_sys_context_reset_enabled_f(void)
1142{
1143 return 0x0;
1144}
1145static inline u32 gr_fecs_ctxsw_reset_ctl_sys_context_reset_disabled_f(void)
1146{
1147 return 0x100;
1148}
1149static inline u32 gr_fecs_ctxsw_reset_ctl_gpc_context_reset_enabled_f(void)
1150{
1151 return 0x0;
1152}
1153static inline u32 gr_fecs_ctxsw_reset_ctl_gpc_context_reset_disabled_f(void)
1154{
1155 return 0x200;
1156}
1157static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_s(void)
1158{
1159 return 1;
1160}
1161static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_f(u32 v)
1162{
1163 return (v & 0x1) << 10;
1164}
1165static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_m(void)
1166{
1167 return 0x1 << 10;
1168}
1169static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_v(u32 r)
1170{
1171 return (r >> 10) & 0x1;
1172}
1173static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_enabled_f(void)
1174{
1175 return 0x0;
1176}
1177static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_disabled_f(void)
1178{
1179 return 0x400;
1180}
1181static inline u32 gr_fecs_ctx_state_store_major_rev_id_r(void)
1182{
1183 return 0x0040960c;
1184}
1185static inline u32 gr_fecs_ctxsw_mailbox_r(u32 i)
1186{
1187 return 0x00409800 + i*4;
1188}
1189static inline u32 gr_fecs_ctxsw_mailbox__size_1_v(void)
1190{
1191 return 0x00000010;
1192}
1193static inline u32 gr_fecs_ctxsw_mailbox_value_f(u32 v)
1194{
1195 return (v & 0xffffffff) << 0;
1196}
1197static inline u32 gr_fecs_ctxsw_mailbox_value_pass_v(void)
1198{
1199 return 0x00000001;
1200}
1201static inline u32 gr_fecs_ctxsw_mailbox_value_fail_v(void)
1202{
1203 return 0x00000002;
1204}
1205static inline u32 gr_fecs_ctxsw_mailbox_set_r(u32 i)
1206{
1207 return 0x004098c0 + i*4;
1208}
1209static inline u32 gr_fecs_ctxsw_mailbox_set_value_f(u32 v)
1210{
1211 return (v & 0xffffffff) << 0;
1212}
1213static inline u32 gr_fecs_ctxsw_mailbox_clear_r(u32 i)
1214{
1215 return 0x00409840 + i*4;
1216}
1217static inline u32 gr_fecs_ctxsw_mailbox_clear_value_f(u32 v)
1218{
1219 return (v & 0xffffffff) << 0;
1220}
1221static inline u32 gr_fecs_fs_r(void)
1222{
1223 return 0x00409604;
1224}
1225static inline u32 gr_fecs_fs_num_available_gpcs_s(void)
1226{
1227 return 5;
1228}
1229static inline u32 gr_fecs_fs_num_available_gpcs_f(u32 v)
1230{
1231 return (v & 0x1f) << 0;
1232}
1233static inline u32 gr_fecs_fs_num_available_gpcs_m(void)
1234{
1235 return 0x1f << 0;
1236}
1237static inline u32 gr_fecs_fs_num_available_gpcs_v(u32 r)
1238{
1239 return (r >> 0) & 0x1f;
1240}
1241static inline u32 gr_fecs_fs_num_available_fbps_s(void)
1242{
1243 return 5;
1244}
1245static inline u32 gr_fecs_fs_num_available_fbps_f(u32 v)
1246{
1247 return (v & 0x1f) << 16;
1248}
1249static inline u32 gr_fecs_fs_num_available_fbps_m(void)
1250{
1251 return 0x1f << 16;
1252}
1253static inline u32 gr_fecs_fs_num_available_fbps_v(u32 r)
1254{
1255 return (r >> 16) & 0x1f;
1256}
1257static inline u32 gr_fecs_cfg_r(void)
1258{
1259 return 0x00409620;
1260}
1261static inline u32 gr_fecs_cfg_imem_sz_v(u32 r)
1262{
1263 return (r >> 0) & 0xff;
1264}
1265static inline u32 gr_fecs_rc_lanes_r(void)
1266{
1267 return 0x00409880;
1268}
1269static inline u32 gr_fecs_rc_lanes_num_chains_s(void)
1270{
1271 return 6;
1272}
1273static inline u32 gr_fecs_rc_lanes_num_chains_f(u32 v)
1274{
1275 return (v & 0x3f) << 0;
1276}
1277static inline u32 gr_fecs_rc_lanes_num_chains_m(void)
1278{
1279 return 0x3f << 0;
1280}
1281static inline u32 gr_fecs_rc_lanes_num_chains_v(u32 r)
1282{
1283 return (r >> 0) & 0x3f;
1284}
1285static inline u32 gr_fecs_ctxsw_status_1_r(void)
1286{
1287 return 0x00409400;
1288}
1289static inline u32 gr_fecs_ctxsw_status_1_arb_busy_s(void)
1290{
1291 return 1;
1292}
1293static inline u32 gr_fecs_ctxsw_status_1_arb_busy_f(u32 v)
1294{
1295 return (v & 0x1) << 12;
1296}
1297static inline u32 gr_fecs_ctxsw_status_1_arb_busy_m(void)
1298{
1299 return 0x1 << 12;
1300}
1301static inline u32 gr_fecs_ctxsw_status_1_arb_busy_v(u32 r)
1302{
1303 return (r >> 12) & 0x1;
1304}
1305static inline u32 gr_fecs_arb_ctx_adr_r(void)
1306{
1307 return 0x00409a24;
1308}
1309static inline u32 gr_fecs_new_ctx_r(void)
1310{
1311 return 0x00409b04;
1312}
1313static inline u32 gr_fecs_new_ctx_ptr_s(void)
1314{
1315 return 28;
1316}
1317static inline u32 gr_fecs_new_ctx_ptr_f(u32 v)
1318{
1319 return (v & 0xfffffff) << 0;
1320}
1321static inline u32 gr_fecs_new_ctx_ptr_m(void)
1322{
1323 return 0xfffffff << 0;
1324}
1325static inline u32 gr_fecs_new_ctx_ptr_v(u32 r)
1326{
1327 return (r >> 0) & 0xfffffff;
1328}
1329static inline u32 gr_fecs_new_ctx_target_s(void)
1330{
1331 return 2;
1332}
1333static inline u32 gr_fecs_new_ctx_target_f(u32 v)
1334{
1335 return (v & 0x3) << 28;
1336}
1337static inline u32 gr_fecs_new_ctx_target_m(void)
1338{
1339 return 0x3 << 28;
1340}
1341static inline u32 gr_fecs_new_ctx_target_v(u32 r)
1342{
1343 return (r >> 28) & 0x3;
1344}
1345static inline u32 gr_fecs_new_ctx_target_vid_mem_f(void)
1346{
1347 return 0x0;
1348}
1349static inline u32 gr_fecs_new_ctx_target_sys_mem_ncoh_f(void)
1350{
1351 return 0x30000000;
1352}
1353static inline u32 gr_fecs_new_ctx_valid_s(void)
1354{
1355 return 1;
1356}
1357static inline u32 gr_fecs_new_ctx_valid_f(u32 v)
1358{
1359 return (v & 0x1) << 31;
1360}
1361static inline u32 gr_fecs_new_ctx_valid_m(void)
1362{
1363 return 0x1 << 31;
1364}
1365static inline u32 gr_fecs_new_ctx_valid_v(u32 r)
1366{
1367 return (r >> 31) & 0x1;
1368}
1369static inline u32 gr_fecs_arb_ctx_ptr_r(void)
1370{
1371 return 0x00409a0c;
1372}
1373static inline u32 gr_fecs_arb_ctx_ptr_ptr_s(void)
1374{
1375 return 28;
1376}
1377static inline u32 gr_fecs_arb_ctx_ptr_ptr_f(u32 v)
1378{
1379 return (v & 0xfffffff) << 0;
1380}
1381static inline u32 gr_fecs_arb_ctx_ptr_ptr_m(void)
1382{
1383 return 0xfffffff << 0;
1384}
1385static inline u32 gr_fecs_arb_ctx_ptr_ptr_v(u32 r)
1386{
1387 return (r >> 0) & 0xfffffff;
1388}
1389static inline u32 gr_fecs_arb_ctx_ptr_target_s(void)
1390{
1391 return 2;
1392}
1393static inline u32 gr_fecs_arb_ctx_ptr_target_f(u32 v)
1394{
1395 return (v & 0x3) << 28;
1396}
1397static inline u32 gr_fecs_arb_ctx_ptr_target_m(void)
1398{
1399 return 0x3 << 28;
1400}
1401static inline u32 gr_fecs_arb_ctx_ptr_target_v(u32 r)
1402{
1403 return (r >> 28) & 0x3;
1404}
1405static inline u32 gr_fecs_arb_ctx_ptr_target_vid_mem_f(void)
1406{
1407 return 0x0;
1408}
1409static inline u32 gr_fecs_arb_ctx_ptr_target_sys_mem_ncoh_f(void)
1410{
1411 return 0x30000000;
1412}
1413static inline u32 gr_fecs_arb_ctx_cmd_r(void)
1414{
1415 return 0x00409a10;
1416}
1417static inline u32 gr_fecs_arb_ctx_cmd_cmd_s(void)
1418{
1419 return 5;
1420}
1421static inline u32 gr_fecs_arb_ctx_cmd_cmd_f(u32 v)
1422{
1423 return (v & 0x1f) << 0;
1424}
1425static inline u32 gr_fecs_arb_ctx_cmd_cmd_m(void)
1426{
1427 return 0x1f << 0;
1428}
1429static inline u32 gr_fecs_arb_ctx_cmd_cmd_v(u32 r)
1430{
1431 return (r >> 0) & 0x1f;
1432}
1433static inline u32 gr_fecs_ctxsw_status_fe_0_r(void)
1434{
1435 return 0x00409c00;
1436}
1437static inline u32 gr_gpc0_gpccs_ctxsw_status_gpc_0_r(void)
1438{
1439 return 0x00502c04;
1440}
1441static inline u32 gr_gpc0_gpccs_ctxsw_status_1_r(void)
1442{
1443 return 0x00502400;
1444}
1445static inline u32 gr_fecs_ctxsw_idlestate_r(void)
1446{
1447 return 0x00409420;
1448}
1449static inline u32 gr_fecs_feature_override_ecc_r(void)
1450{
1451 return 0x00409658;
1452}
1453static inline u32 gr_gpc0_gpccs_ctxsw_idlestate_r(void)
1454{
1455 return 0x00502420;
1456}
1457static inline u32 gr_rstr2d_gpc_map0_r(void)
1458{
1459 return 0x0040780c;
1460}
1461static inline u32 gr_rstr2d_gpc_map1_r(void)
1462{
1463 return 0x00407810;
1464}
1465static inline u32 gr_rstr2d_gpc_map2_r(void)
1466{
1467 return 0x00407814;
1468}
1469static inline u32 gr_rstr2d_gpc_map3_r(void)
1470{
1471 return 0x00407818;
1472}
1473static inline u32 gr_rstr2d_gpc_map4_r(void)
1474{
1475 return 0x0040781c;
1476}
1477static inline u32 gr_rstr2d_gpc_map5_r(void)
1478{
1479 return 0x00407820;
1480}
1481static inline u32 gr_rstr2d_map_table_cfg_r(void)
1482{
1483 return 0x004078bc;
1484}
1485static inline u32 gr_rstr2d_map_table_cfg_row_offset_f(u32 v)
1486{
1487 return (v & 0xff) << 0;
1488}
1489static inline u32 gr_rstr2d_map_table_cfg_num_entries_f(u32 v)
1490{
1491 return (v & 0xff) << 8;
1492}
1493static inline u32 gr_pd_hww_esr_r(void)
1494{
1495 return 0x00406018;
1496}
1497static inline u32 gr_pd_hww_esr_reset_active_f(void)
1498{
1499 return 0x40000000;
1500}
1501static inline u32 gr_pd_hww_esr_en_enable_f(void)
1502{
1503 return 0x80000000;
1504}
1505static inline u32 gr_pd_num_tpc_per_gpc_r(u32 i)
1506{
1507 return 0x00406028 + i*4;
1508}
1509static inline u32 gr_pd_num_tpc_per_gpc__size_1_v(void)
1510{
1511 return 0x00000004;
1512}
1513static inline u32 gr_pd_num_tpc_per_gpc_count0_f(u32 v)
1514{
1515 return (v & 0xf) << 0;
1516}
1517static inline u32 gr_pd_num_tpc_per_gpc_count1_f(u32 v)
1518{
1519 return (v & 0xf) << 4;
1520}
1521static inline u32 gr_pd_num_tpc_per_gpc_count2_f(u32 v)
1522{
1523 return (v & 0xf) << 8;
1524}
1525static inline u32 gr_pd_num_tpc_per_gpc_count3_f(u32 v)
1526{
1527 return (v & 0xf) << 12;
1528}
1529static inline u32 gr_pd_num_tpc_per_gpc_count4_f(u32 v)
1530{
1531 return (v & 0xf) << 16;
1532}
1533static inline u32 gr_pd_num_tpc_per_gpc_count5_f(u32 v)
1534{
1535 return (v & 0xf) << 20;
1536}
1537static inline u32 gr_pd_num_tpc_per_gpc_count6_f(u32 v)
1538{
1539 return (v & 0xf) << 24;
1540}
1541static inline u32 gr_pd_num_tpc_per_gpc_count7_f(u32 v)
1542{
1543 return (v & 0xf) << 28;
1544}
1545static inline u32 gr_pd_ab_dist_cfg0_r(void)
1546{
1547 return 0x004064c0;
1548}
1549static inline u32 gr_pd_ab_dist_cfg0_timeslice_enable_en_f(void)
1550{
1551 return 0x80000000;
1552}
1553static inline u32 gr_pd_ab_dist_cfg0_timeslice_enable_dis_f(void)
1554{
1555 return 0x0;
1556}
1557static inline u32 gr_pd_ab_dist_cfg1_r(void)
1558{
1559 return 0x004064c4;
1560}
1561static inline u32 gr_pd_ab_dist_cfg1_max_batches_init_f(void)
1562{
1563 return 0xffff;
1564}
1565static inline u32 gr_pd_ab_dist_cfg1_max_output_f(u32 v)
1566{
1567 return (v & 0xffff) << 16;
1568}
1569static inline u32 gr_pd_ab_dist_cfg1_max_output_granularity_v(void)
1570{
1571 return 0x00000080;
1572}
1573static inline u32 gr_pd_ab_dist_cfg2_r(void)
1574{
1575 return 0x004064c8;
1576}
1577static inline u32 gr_pd_ab_dist_cfg2_token_limit_f(u32 v)
1578{
1579 return (v & 0x1fff) << 0;
1580}
1581static inline u32 gr_pd_ab_dist_cfg2_token_limit_init_v(void)
1582{
1583 return 0x00000900;
1584}
1585static inline u32 gr_pd_ab_dist_cfg2_state_limit_f(u32 v)
1586{
1587 return (v & 0x1fff) << 16;
1588}
1589static inline u32 gr_pd_ab_dist_cfg2_state_limit_scc_bundle_granularity_v(void)
1590{
1591 return 0x00000020;
1592}
1593static inline u32 gr_pd_ab_dist_cfg2_state_limit_min_gpm_fifo_depths_v(void)
1594{
1595 return 0x00000900;
1596}
1597static inline u32 gr_pd_dist_skip_table_r(u32 i)
1598{
1599 return 0x004064d0 + i*4;
1600}
1601static inline u32 gr_pd_dist_skip_table__size_1_v(void)
1602{
1603 return 0x00000008;
1604}
1605static inline u32 gr_pd_dist_skip_table_gpc_4n0_mask_f(u32 v)
1606{
1607 return (v & 0xff) << 0;
1608}
1609static inline u32 gr_pd_dist_skip_table_gpc_4n1_mask_f(u32 v)
1610{
1611 return (v & 0xff) << 8;
1612}
1613static inline u32 gr_pd_dist_skip_table_gpc_4n2_mask_f(u32 v)
1614{
1615 return (v & 0xff) << 16;
1616}
1617static inline u32 gr_pd_dist_skip_table_gpc_4n3_mask_f(u32 v)
1618{
1619 return (v & 0xff) << 24;
1620}
1621static inline u32 gr_ds_debug_r(void)
1622{
1623 return 0x00405800;
1624}
1625static inline u32 gr_ds_debug_timeslice_mode_disable_f(void)
1626{
1627 return 0x0;
1628}
1629static inline u32 gr_ds_debug_timeslice_mode_enable_f(void)
1630{
1631 return 0x8000000;
1632}
1633static inline u32 gr_ds_zbc_color_r_r(void)
1634{
1635 return 0x00405804;
1636}
1637static inline u32 gr_ds_zbc_color_r_val_f(u32 v)
1638{
1639 return (v & 0xffffffff) << 0;
1640}
1641static inline u32 gr_ds_zbc_color_g_r(void)
1642{
1643 return 0x00405808;
1644}
1645static inline u32 gr_ds_zbc_color_g_val_f(u32 v)
1646{
1647 return (v & 0xffffffff) << 0;
1648}
1649static inline u32 gr_ds_zbc_color_b_r(void)
1650{
1651 return 0x0040580c;
1652}
1653static inline u32 gr_ds_zbc_color_b_val_f(u32 v)
1654{
1655 return (v & 0xffffffff) << 0;
1656}
1657static inline u32 gr_ds_zbc_color_a_r(void)
1658{
1659 return 0x00405810;
1660}
1661static inline u32 gr_ds_zbc_color_a_val_f(u32 v)
1662{
1663 return (v & 0xffffffff) << 0;
1664}
1665static inline u32 gr_ds_zbc_color_fmt_r(void)
1666{
1667 return 0x00405814;
1668}
1669static inline u32 gr_ds_zbc_color_fmt_val_f(u32 v)
1670{
1671 return (v & 0x7f) << 0;
1672}
1673static inline u32 gr_ds_zbc_color_fmt_val_invalid_f(void)
1674{
1675 return 0x0;
1676}
1677static inline u32 gr_ds_zbc_color_fmt_val_zero_v(void)
1678{
1679 return 0x00000001;
1680}
1681static inline u32 gr_ds_zbc_color_fmt_val_unorm_one_v(void)
1682{
1683 return 0x00000002;
1684}
1685static inline u32 gr_ds_zbc_color_fmt_val_rf32_gf32_bf32_af32_v(void)
1686{
1687 return 0x00000004;
1688}
1689static inline u32 gr_ds_zbc_color_fmt_val_a8_b8_g8_r8_v(void)
1690{
1691 return 0x00000028;
1692}
1693static inline u32 gr_ds_zbc_z_r(void)
1694{
1695 return 0x00405818;
1696}
1697static inline u32 gr_ds_zbc_z_val_s(void)
1698{
1699 return 32;
1700}
1701static inline u32 gr_ds_zbc_z_val_f(u32 v)
1702{
1703 return (v & 0xffffffff) << 0;
1704}
1705static inline u32 gr_ds_zbc_z_val_m(void)
1706{
1707 return 0xffffffff << 0;
1708}
1709static inline u32 gr_ds_zbc_z_val_v(u32 r)
1710{
1711 return (r >> 0) & 0xffffffff;
1712}
1713static inline u32 gr_ds_zbc_z_val__init_v(void)
1714{
1715 return 0x00000000;
1716}
1717static inline u32 gr_ds_zbc_z_val__init_f(void)
1718{
1719 return 0x0;
1720}
1721static inline u32 gr_ds_zbc_z_fmt_r(void)
1722{
1723 return 0x0040581c;
1724}
1725static inline u32 gr_ds_zbc_z_fmt_val_f(u32 v)
1726{
1727 return (v & 0x1) << 0;
1728}
1729static inline u32 gr_ds_zbc_z_fmt_val_invalid_f(void)
1730{
1731 return 0x0;
1732}
1733static inline u32 gr_ds_zbc_z_fmt_val_fp32_v(void)
1734{
1735 return 0x00000001;
1736}
1737static inline u32 gr_ds_zbc_tbl_index_r(void)
1738{
1739 return 0x00405820;
1740}
1741static inline u32 gr_ds_zbc_tbl_index_val_f(u32 v)
1742{
1743 return (v & 0xf) << 0;
1744}
1745static inline u32 gr_ds_zbc_tbl_ld_r(void)
1746{
1747 return 0x00405824;
1748}
1749static inline u32 gr_ds_zbc_tbl_ld_select_c_f(void)
1750{
1751 return 0x0;
1752}
1753static inline u32 gr_ds_zbc_tbl_ld_select_z_f(void)
1754{
1755 return 0x1;
1756}
1757static inline u32 gr_ds_zbc_tbl_ld_action_write_f(void)
1758{
1759 return 0x0;
1760}
1761static inline u32 gr_ds_zbc_tbl_ld_trigger_active_f(void)
1762{
1763 return 0x4;
1764}
1765static inline u32 gr_ds_tga_constraintlogic_beta_r(void)
1766{
1767 return 0x00405830;
1768}
1769static inline u32 gr_ds_tga_constraintlogic_beta_cbsize_f(u32 v)
1770{
1771 return (v & 0x3fffff) << 0;
1772}
1773static inline u32 gr_ds_tga_constraintlogic_alpha_r(void)
1774{
1775 return 0x0040585c;
1776}
1777static inline u32 gr_ds_tga_constraintlogic_alpha_cbsize_f(u32 v)
1778{
1779 return (v & 0xffff) << 0;
1780}
1781static inline u32 gr_ds_hww_esr_r(void)
1782{
1783 return 0x00405840;
1784}
1785static inline u32 gr_ds_hww_esr_reset_s(void)
1786{
1787 return 1;
1788}
1789static inline u32 gr_ds_hww_esr_reset_f(u32 v)
1790{
1791 return (v & 0x1) << 30;
1792}
1793static inline u32 gr_ds_hww_esr_reset_m(void)
1794{
1795 return 0x1 << 30;
1796}
1797static inline u32 gr_ds_hww_esr_reset_v(u32 r)
1798{
1799 return (r >> 30) & 0x1;
1800}
1801static inline u32 gr_ds_hww_esr_reset_task_v(void)
1802{
1803 return 0x00000001;
1804}
1805static inline u32 gr_ds_hww_esr_reset_task_f(void)
1806{
1807 return 0x40000000;
1808}
1809static inline u32 gr_ds_hww_esr_en_enabled_f(void)
1810{
1811 return 0x80000000;
1812}
1813static inline u32 gr_ds_hww_esr_2_r(void)
1814{
1815 return 0x00405848;
1816}
1817static inline u32 gr_ds_hww_esr_2_reset_s(void)
1818{
1819 return 1;
1820}
1821static inline u32 gr_ds_hww_esr_2_reset_f(u32 v)
1822{
1823 return (v & 0x1) << 30;
1824}
1825static inline u32 gr_ds_hww_esr_2_reset_m(void)
1826{
1827 return 0x1 << 30;
1828}
1829static inline u32 gr_ds_hww_esr_2_reset_v(u32 r)
1830{
1831 return (r >> 30) & 0x1;
1832}
1833static inline u32 gr_ds_hww_esr_2_reset_task_v(void)
1834{
1835 return 0x00000001;
1836}
1837static inline u32 gr_ds_hww_esr_2_reset_task_f(void)
1838{
1839 return 0x40000000;
1840}
1841static inline u32 gr_ds_hww_esr_2_en_enabled_f(void)
1842{
1843 return 0x80000000;
1844}
1845static inline u32 gr_ds_hww_report_mask_r(void)
1846{
1847 return 0x00405844;
1848}
1849static inline u32 gr_ds_hww_report_mask_sph0_err_report_f(void)
1850{
1851 return 0x1;
1852}
1853static inline u32 gr_ds_hww_report_mask_sph1_err_report_f(void)
1854{
1855 return 0x2;
1856}
1857static inline u32 gr_ds_hww_report_mask_sph2_err_report_f(void)
1858{
1859 return 0x4;
1860}
1861static inline u32 gr_ds_hww_report_mask_sph3_err_report_f(void)
1862{
1863 return 0x8;
1864}
1865static inline u32 gr_ds_hww_report_mask_sph4_err_report_f(void)
1866{
1867 return 0x10;
1868}
1869static inline u32 gr_ds_hww_report_mask_sph5_err_report_f(void)
1870{
1871 return 0x20;
1872}
1873static inline u32 gr_ds_hww_report_mask_sph6_err_report_f(void)
1874{
1875 return 0x40;
1876}
1877static inline u32 gr_ds_hww_report_mask_sph7_err_report_f(void)
1878{
1879 return 0x80;
1880}
1881static inline u32 gr_ds_hww_report_mask_sph8_err_report_f(void)
1882{
1883 return 0x100;
1884}
1885static inline u32 gr_ds_hww_report_mask_sph9_err_report_f(void)
1886{
1887 return 0x200;
1888}
1889static inline u32 gr_ds_hww_report_mask_sph10_err_report_f(void)
1890{
1891 return 0x400;
1892}
1893static inline u32 gr_ds_hww_report_mask_sph11_err_report_f(void)
1894{
1895 return 0x800;
1896}
1897static inline u32 gr_ds_hww_report_mask_sph12_err_report_f(void)
1898{
1899 return 0x1000;
1900}
1901static inline u32 gr_ds_hww_report_mask_sph13_err_report_f(void)
1902{
1903 return 0x2000;
1904}
1905static inline u32 gr_ds_hww_report_mask_sph14_err_report_f(void)
1906{
1907 return 0x4000;
1908}
1909static inline u32 gr_ds_hww_report_mask_sph15_err_report_f(void)
1910{
1911 return 0x8000;
1912}
1913static inline u32 gr_ds_hww_report_mask_sph16_err_report_f(void)
1914{
1915 return 0x10000;
1916}
1917static inline u32 gr_ds_hww_report_mask_sph17_err_report_f(void)
1918{
1919 return 0x20000;
1920}
1921static inline u32 gr_ds_hww_report_mask_sph18_err_report_f(void)
1922{
1923 return 0x40000;
1924}
1925static inline u32 gr_ds_hww_report_mask_sph19_err_report_f(void)
1926{
1927 return 0x80000;
1928}
1929static inline u32 gr_ds_hww_report_mask_sph20_err_report_f(void)
1930{
1931 return 0x100000;
1932}
1933static inline u32 gr_ds_hww_report_mask_sph21_err_report_f(void)
1934{
1935 return 0x200000;
1936}
1937static inline u32 gr_ds_hww_report_mask_sph22_err_report_f(void)
1938{
1939 return 0x400000;
1940}
1941static inline u32 gr_ds_hww_report_mask_sph23_err_report_f(void)
1942{
1943 return 0x800000;
1944}
1945static inline u32 gr_ds_hww_report_mask_2_r(void)
1946{
1947 return 0x0040584c;
1948}
1949static inline u32 gr_ds_hww_report_mask_2_sph24_err_report_f(void)
1950{
1951 return 0x1;
1952}
1953static inline u32 gr_ds_num_tpc_per_gpc_r(u32 i)
1954{
1955 return 0x00405870 + i*4;
1956}
1957static inline u32 gr_scc_bundle_cb_base_r(void)
1958{
1959 return 0x00408004;
1960}
1961static inline u32 gr_scc_bundle_cb_base_addr_39_8_f(u32 v)
1962{
1963 return (v & 0xffffffff) << 0;
1964}
1965static inline u32 gr_scc_bundle_cb_base_addr_39_8_align_bits_v(void)
1966{
1967 return 0x00000008;
1968}
1969static inline u32 gr_scc_bundle_cb_size_r(void)
1970{
1971 return 0x00408008;
1972}
1973static inline u32 gr_scc_bundle_cb_size_div_256b_f(u32 v)
1974{
1975 return (v & 0x7ff) << 0;
1976}
1977static inline u32 gr_scc_bundle_cb_size_div_256b__prod_v(void)
1978{
1979 return 0x00000030;
1980}
1981static inline u32 gr_scc_bundle_cb_size_div_256b_byte_granularity_v(void)
1982{
1983 return 0x00000100;
1984}
1985static inline u32 gr_scc_bundle_cb_size_valid_false_v(void)
1986{
1987 return 0x00000000;
1988}
1989static inline u32 gr_scc_bundle_cb_size_valid_false_f(void)
1990{
1991 return 0x0;
1992}
1993static inline u32 gr_scc_bundle_cb_size_valid_true_f(void)
1994{
1995 return 0x80000000;
1996}
1997static inline u32 gr_scc_pagepool_base_r(void)
1998{
1999 return 0x0040800c;
2000}
2001static inline u32 gr_scc_pagepool_base_addr_39_8_f(u32 v)
2002{
2003 return (v & 0xffffffff) << 0;
2004}
2005static inline u32 gr_scc_pagepool_base_addr_39_8_align_bits_v(void)
2006{
2007 return 0x00000008;
2008}
2009static inline u32 gr_scc_pagepool_r(void)
2010{
2011 return 0x00408010;
2012}
2013static inline u32 gr_scc_pagepool_total_pages_f(u32 v)
2014{
2015 return (v & 0x3ff) << 0;
2016}
2017static inline u32 gr_scc_pagepool_total_pages_hwmax_v(void)
2018{
2019 return 0x00000000;
2020}
2021static inline u32 gr_scc_pagepool_total_pages_hwmax_value_v(void)
2022{
2023 return 0x00000200;
2024}
2025static inline u32 gr_scc_pagepool_total_pages_byte_granularity_v(void)
2026{
2027 return 0x00000100;
2028}
2029static inline u32 gr_scc_pagepool_max_valid_pages_s(void)
2030{
2031 return 10;
2032}
2033static inline u32 gr_scc_pagepool_max_valid_pages_f(u32 v)
2034{
2035 return (v & 0x3ff) << 10;
2036}
2037static inline u32 gr_scc_pagepool_max_valid_pages_m(void)
2038{
2039 return 0x3ff << 10;
2040}
2041static inline u32 gr_scc_pagepool_max_valid_pages_v(u32 r)
2042{
2043 return (r >> 10) & 0x3ff;
2044}
2045static inline u32 gr_scc_pagepool_valid_true_f(void)
2046{
2047 return 0x80000000;
2048}
2049static inline u32 gr_scc_init_r(void)
2050{
2051 return 0x0040802c;
2052}
2053static inline u32 gr_scc_init_ram_trigger_f(void)
2054{
2055 return 0x1;
2056}
2057static inline u32 gr_scc_hww_esr_r(void)
2058{
2059 return 0x00408030;
2060}
2061static inline u32 gr_scc_hww_esr_reset_active_f(void)
2062{
2063 return 0x40000000;
2064}
2065static inline u32 gr_scc_hww_esr_en_enable_f(void)
2066{
2067 return 0x80000000;
2068}
2069static inline u32 gr_sked_hww_esr_r(void)
2070{
2071 return 0x00407020;
2072}
2073static inline u32 gr_sked_hww_esr_reset_active_f(void)
2074{
2075 return 0x40000000;
2076}
2077static inline u32 gr_cwd_fs_r(void)
2078{
2079 return 0x00405b00;
2080}
2081static inline u32 gr_cwd_fs_num_gpcs_f(u32 v)
2082{
2083 return (v & 0xff) << 0;
2084}
2085static inline u32 gr_cwd_fs_num_tpcs_f(u32 v)
2086{
2087 return (v & 0xff) << 8;
2088}
2089static inline u32 gr_cwd_gpc_tpc_id_r(u32 i)
2090{
2091 return 0x00405b60 + i*4;
2092}
2093static inline u32 gr_cwd_gpc_tpc_id_tpc0_f(u32 v)
2094{
2095 return (v & 0xf) << 0;
2096}
2097static inline u32 gr_cwd_gpc_tpc_id_tpc1_f(u32 v)
2098{
2099 return (v & 0xf) << 8;
2100}
2101static inline u32 gr_cwd_sm_id_r(u32 i)
2102{
2103 return 0x00405ba0 + i*4;
2104}
2105static inline u32 gr_cwd_sm_id_tpc0_f(u32 v)
2106{
2107 return (v & 0xff) << 0;
2108}
2109static inline u32 gr_cwd_sm_id_tpc1_f(u32 v)
2110{
2111 return (v & 0xff) << 8;
2112}
2113static inline u32 gr_gpc0_fs_gpc_r(void)
2114{
2115 return 0x00502608;
2116}
2117static inline u32 gr_gpc0_fs_gpc_num_available_tpcs_v(u32 r)
2118{
2119 return (r >> 0) & 0x1f;
2120}
2121static inline u32 gr_gpc0_fs_gpc_num_available_zculls_v(u32 r)
2122{
2123 return (r >> 16) & 0x1f;
2124}
2125static inline u32 gr_gpc0_cfg_r(void)
2126{
2127 return 0x00502620;
2128}
2129static inline u32 gr_gpc0_cfg_imem_sz_v(u32 r)
2130{
2131 return (r >> 0) & 0xff;
2132}
2133static inline u32 gr_gpccs_rc_lanes_r(void)
2134{
2135 return 0x00502880;
2136}
2137static inline u32 gr_gpccs_rc_lanes_num_chains_s(void)
2138{
2139 return 6;
2140}
2141static inline u32 gr_gpccs_rc_lanes_num_chains_f(u32 v)
2142{
2143 return (v & 0x3f) << 0;
2144}
2145static inline u32 gr_gpccs_rc_lanes_num_chains_m(void)
2146{
2147 return 0x3f << 0;
2148}
2149static inline u32 gr_gpccs_rc_lanes_num_chains_v(u32 r)
2150{
2151 return (r >> 0) & 0x3f;
2152}
2153static inline u32 gr_gpccs_rc_lane_size_r(void)
2154{
2155 return 0x00502910;
2156}
2157static inline u32 gr_gpccs_rc_lane_size_v_s(void)
2158{
2159 return 24;
2160}
2161static inline u32 gr_gpccs_rc_lane_size_v_f(u32 v)
2162{
2163 return (v & 0xffffff) << 0;
2164}
2165static inline u32 gr_gpccs_rc_lane_size_v_m(void)
2166{
2167 return 0xffffff << 0;
2168}
2169static inline u32 gr_gpccs_rc_lane_size_v_v(u32 r)
2170{
2171 return (r >> 0) & 0xffffff;
2172}
2173static inline u32 gr_gpccs_rc_lane_size_v_0_v(void)
2174{
2175 return 0x00000000;
2176}
2177static inline u32 gr_gpccs_rc_lane_size_v_0_f(void)
2178{
2179 return 0x0;
2180}
2181static inline u32 gr_gpc0_zcull_fs_r(void)
2182{
2183 return 0x00500910;
2184}
2185static inline u32 gr_gpc0_zcull_fs_num_sms_f(u32 v)
2186{
2187 return (v & 0x1ff) << 0;
2188}
2189static inline u32 gr_gpc0_zcull_fs_num_active_banks_f(u32 v)
2190{
2191 return (v & 0xf) << 16;
2192}
2193static inline u32 gr_gpc0_zcull_ram_addr_r(void)
2194{
2195 return 0x00500914;
2196}
2197static inline u32 gr_gpc0_zcull_ram_addr_tiles_per_hypertile_row_per_gpc_f(u32 v)
2198{
2199 return (v & 0xf) << 0;
2200}
2201static inline u32 gr_gpc0_zcull_ram_addr_row_offset_f(u32 v)
2202{
2203 return (v & 0xf) << 8;
2204}
2205static inline u32 gr_gpc0_zcull_sm_num_rcp_r(void)
2206{
2207 return 0x00500918;
2208}
2209static inline u32 gr_gpc0_zcull_sm_num_rcp_conservative_f(u32 v)
2210{
2211 return (v & 0xffffff) << 0;
2212}
2213static inline u32 gr_gpc0_zcull_sm_num_rcp_conservative__max_v(void)
2214{
2215 return 0x00800000;
2216}
2217static inline u32 gr_gpc0_zcull_total_ram_size_r(void)
2218{
2219 return 0x00500920;
2220}
2221static inline u32 gr_gpc0_zcull_total_ram_size_num_aliquots_f(u32 v)
2222{
2223 return (v & 0xffff) << 0;
2224}
2225static inline u32 gr_gpc0_zcull_zcsize_r(u32 i)
2226{
2227 return 0x00500a04 + i*32;
2228}
2229static inline u32 gr_gpc0_zcull_zcsize_height_subregion__multiple_v(void)
2230{
2231 return 0x00000040;
2232}
2233static inline u32 gr_gpc0_zcull_zcsize_width_subregion__multiple_v(void)
2234{
2235 return 0x00000010;
2236}
2237static inline u32 gr_gpc0_gpm_pd_sm_id_r(u32 i)
2238{
2239 return 0x00500c10 + i*4;
2240}
2241static inline u32 gr_gpc0_gpm_pd_sm_id_id_f(u32 v)
2242{
2243 return (v & 0xff) << 0;
2244}
2245static inline u32 gr_gpc0_gpm_pd_pes_tpc_id_mask_r(u32 i)
2246{
2247 return 0x00500c30 + i*4;
2248}
2249static inline u32 gr_gpc0_gpm_pd_pes_tpc_id_mask_mask_v(u32 r)
2250{
2251 return (r >> 0) & 0xff;
2252}
2253static inline u32 gr_gpc0_tpc0_pe_cfg_smid_r(void)
2254{
2255 return 0x00504088;
2256}
2257static inline u32 gr_gpc0_tpc0_pe_cfg_smid_value_f(u32 v)
2258{
2259 return (v & 0xffff) << 0;
2260}
2261static inline u32 gr_gpc0_tpc0_sm_cfg_r(void)
2262{
2263 return 0x00504698;
2264}
2265static inline u32 gr_gpc0_tpc0_sm_cfg_sm_id_f(u32 v)
2266{
2267 return (v & 0xffff) << 0;
2268}
2269static inline u32 gr_gpc0_tpc0_sm_arch_r(void)
2270{
2271 return 0x0050469c;
2272}
2273static inline u32 gr_gpc0_tpc0_sm_arch_warp_count_v(u32 r)
2274{
2275 return (r >> 0) & 0xff;
2276}
2277static inline u32 gr_gpc0_tpc0_sm_arch_spa_version_v(u32 r)
2278{
2279 return (r >> 8) & 0xfff;
2280}
2281static inline u32 gr_gpc0_tpc0_sm_arch_sm_version_v(u32 r)
2282{
2283 return (r >> 20) & 0xfff;
2284}
2285static inline u32 gr_gpc0_ppc0_pes_vsc_strem_r(void)
2286{
2287 return 0x00503018;
2288}
2289static inline u32 gr_gpc0_ppc0_pes_vsc_strem_master_pe_m(void)
2290{
2291 return 0x1 << 0;
2292}
2293static inline u32 gr_gpc0_ppc0_pes_vsc_strem_master_pe_true_f(void)
2294{
2295 return 0x1;
2296}
2297static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_r(void)
2298{
2299 return 0x005030c0;
2300}
2301static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_f(u32 v)
2302{
2303 return (v & 0x3fffff) << 0;
2304}
2305static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_m(void)
2306{
2307 return 0x3fffff << 0;
2308}
2309static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v(void)
2310{
2311 return 0x00000320;
2312}
2313static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v(void)
2314{
2315 return 0x00000ba8;
2316}
2317static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_granularity_v(void)
2318{
2319 return 0x00000020;
2320}
2321static inline u32 gr_gpc0_ppc0_cbm_beta_cb_offset_r(void)
2322{
2323 return 0x005030f4;
2324}
2325static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_r(void)
2326{
2327 return 0x005030e4;
2328}
2329static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_v_f(u32 v)
2330{
2331 return (v & 0xffff) << 0;
2332}
2333static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_v_m(void)
2334{
2335 return 0xffff << 0;
2336}
2337static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_v_default_v(void)
2338{
2339 return 0x00000800;
2340}
2341static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_v_granularity_v(void)
2342{
2343 return 0x00000020;
2344}
2345static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_offset_r(void)
2346{
2347 return 0x005030f8;
2348}
2349static inline u32 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_r(void)
2350{
2351 return 0x005030f0;
2352}
2353static inline u32 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_v_f(u32 v)
2354{
2355 return (v & 0x3fffff) << 0;
2356}
2357static inline u32 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_v_default_v(void)
2358{
2359 return 0x00000320;
2360}
2361static inline u32 gr_gpcs_tpcs_tex_rm_cb_0_r(void)
2362{
2363 return 0x00419b00;
2364}
2365static inline u32 gr_gpcs_tpcs_tex_rm_cb_0_base_addr_43_12_f(u32 v)
2366{
2367 return (v & 0xffffffff) << 0;
2368}
2369static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_r(void)
2370{
2371 return 0x00419b04;
2372}
2373static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_s(void)
2374{
2375 return 21;
2376}
2377static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_f(u32 v)
2378{
2379 return (v & 0x1fffff) << 0;
2380}
2381static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_m(void)
2382{
2383 return 0x1fffff << 0;
2384}
2385static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_v(u32 r)
2386{
2387 return (r >> 0) & 0x1fffff;
2388}
2389static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_granularity_f(void)
2390{
2391 return 0x80;
2392}
2393static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_s(void)
2394{
2395 return 1;
2396}
2397static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_f(u32 v)
2398{
2399 return (v & 0x1) << 31;
2400}
2401static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_m(void)
2402{
2403 return 0x1 << 31;
2404}
2405static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_v(u32 r)
2406{
2407 return (r >> 31) & 0x1;
2408}
2409static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_true_f(void)
2410{
2411 return 0x80000000;
2412}
2413static inline u32 gr_gpccs_falcon_addr_r(void)
2414{
2415 return 0x0041a0ac;
2416}
2417static inline u32 gr_gpccs_falcon_addr_lsb_s(void)
2418{
2419 return 6;
2420}
2421static inline u32 gr_gpccs_falcon_addr_lsb_f(u32 v)
2422{
2423 return (v & 0x3f) << 0;
2424}
2425static inline u32 gr_gpccs_falcon_addr_lsb_m(void)
2426{
2427 return 0x3f << 0;
2428}
2429static inline u32 gr_gpccs_falcon_addr_lsb_v(u32 r)
2430{
2431 return (r >> 0) & 0x3f;
2432}
2433static inline u32 gr_gpccs_falcon_addr_lsb_init_v(void)
2434{
2435 return 0x00000000;
2436}
2437static inline u32 gr_gpccs_falcon_addr_lsb_init_f(void)
2438{
2439 return 0x0;
2440}
2441static inline u32 gr_gpccs_falcon_addr_msb_s(void)
2442{
2443 return 6;
2444}
2445static inline u32 gr_gpccs_falcon_addr_msb_f(u32 v)
2446{
2447 return (v & 0x3f) << 6;
2448}
2449static inline u32 gr_gpccs_falcon_addr_msb_m(void)
2450{
2451 return 0x3f << 6;
2452}
2453static inline u32 gr_gpccs_falcon_addr_msb_v(u32 r)
2454{
2455 return (r >> 6) & 0x3f;
2456}
2457static inline u32 gr_gpccs_falcon_addr_msb_init_v(void)
2458{
2459 return 0x00000000;
2460}
2461static inline u32 gr_gpccs_falcon_addr_msb_init_f(void)
2462{
2463 return 0x0;
2464}
2465static inline u32 gr_gpccs_falcon_addr_ext_s(void)
2466{
2467 return 12;
2468}
2469static inline u32 gr_gpccs_falcon_addr_ext_f(u32 v)
2470{
2471 return (v & 0xfff) << 0;
2472}
2473static inline u32 gr_gpccs_falcon_addr_ext_m(void)
2474{
2475 return 0xfff << 0;
2476}
2477static inline u32 gr_gpccs_falcon_addr_ext_v(u32 r)
2478{
2479 return (r >> 0) & 0xfff;
2480}
2481static inline u32 gr_gpccs_cpuctl_r(void)
2482{
2483 return 0x0041a100;
2484}
2485static inline u32 gr_gpccs_cpuctl_startcpu_f(u32 v)
2486{
2487 return (v & 0x1) << 1;
2488}
2489static inline u32 gr_gpccs_dmactl_r(void)
2490{
2491 return 0x0041a10c;
2492}
2493static inline u32 gr_gpccs_dmactl_require_ctx_f(u32 v)
2494{
2495 return (v & 0x1) << 0;
2496}
2497static inline u32 gr_gpccs_dmactl_dmem_scrubbing_m(void)
2498{
2499 return 0x1 << 1;
2500}
2501static inline u32 gr_gpccs_dmactl_imem_scrubbing_m(void)
2502{
2503 return 0x1 << 2;
2504}
2505static inline u32 gr_gpccs_imemc_r(u32 i)
2506{
2507 return 0x0041a180 + i*16;
2508}
2509static inline u32 gr_gpccs_imemc_offs_f(u32 v)
2510{
2511 return (v & 0x3f) << 2;
2512}
2513static inline u32 gr_gpccs_imemc_blk_f(u32 v)
2514{
2515 return (v & 0xff) << 8;
2516}
2517static inline u32 gr_gpccs_imemc_aincw_f(u32 v)
2518{
2519 return (v & 0x1) << 24;
2520}
2521static inline u32 gr_gpccs_imemd_r(u32 i)
2522{
2523 return 0x0041a184 + i*16;
2524}
2525static inline u32 gr_gpccs_imemt_r(u32 i)
2526{
2527 return 0x0041a188 + i*16;
2528}
2529static inline u32 gr_gpccs_imemt__size_1_v(void)
2530{
2531 return 0x00000004;
2532}
2533static inline u32 gr_gpccs_imemt_tag_f(u32 v)
2534{
2535 return (v & 0xffff) << 0;
2536}
2537static inline u32 gr_gpccs_dmemc_r(u32 i)
2538{
2539 return 0x0041a1c0 + i*8;
2540}
2541static inline u32 gr_gpccs_dmemc_offs_f(u32 v)
2542{
2543 return (v & 0x3f) << 2;
2544}
2545static inline u32 gr_gpccs_dmemc_blk_f(u32 v)
2546{
2547 return (v & 0xff) << 8;
2548}
2549static inline u32 gr_gpccs_dmemc_aincw_f(u32 v)
2550{
2551 return (v & 0x1) << 24;
2552}
2553static inline u32 gr_gpccs_dmemd_r(u32 i)
2554{
2555 return 0x0041a1c4 + i*8;
2556}
2557static inline u32 gr_gpccs_ctxsw_mailbox_r(u32 i)
2558{
2559 return 0x0041a800 + i*4;
2560}
2561static inline u32 gr_gpccs_ctxsw_mailbox_value_f(u32 v)
2562{
2563 return (v & 0xffffffff) << 0;
2564}
2565static inline u32 gr_gpcs_swdx_bundle_cb_base_r(void)
2566{
2567 return 0x00418e24;
2568}
2569static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_s(void)
2570{
2571 return 32;
2572}
2573static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_f(u32 v)
2574{
2575 return (v & 0xffffffff) << 0;
2576}
2577static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_m(void)
2578{
2579 return 0xffffffff << 0;
2580}
2581static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_v(u32 r)
2582{
2583 return (r >> 0) & 0xffffffff;
2584}
2585static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_init_v(void)
2586{
2587 return 0x00000000;
2588}
2589static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_init_f(void)
2590{
2591 return 0x0;
2592}
2593static inline u32 gr_gpcs_swdx_bundle_cb_size_r(void)
2594{
2595 return 0x00418e28;
2596}
2597static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_s(void)
2598{
2599 return 11;
2600}
2601static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_f(u32 v)
2602{
2603 return (v & 0x7ff) << 0;
2604}
2605static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_m(void)
2606{
2607 return 0x7ff << 0;
2608}
2609static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_v(u32 r)
2610{
2611 return (r >> 0) & 0x7ff;
2612}
2613static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_init_v(void)
2614{
2615 return 0x00000030;
2616}
2617static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_init_f(void)
2618{
2619 return 0x30;
2620}
2621static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_s(void)
2622{
2623 return 1;
2624}
2625static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_f(u32 v)
2626{
2627 return (v & 0x1) << 31;
2628}
2629static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_m(void)
2630{
2631 return 0x1 << 31;
2632}
2633static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_v(u32 r)
2634{
2635 return (r >> 31) & 0x1;
2636}
2637static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_false_v(void)
2638{
2639 return 0x00000000;
2640}
2641static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_false_f(void)
2642{
2643 return 0x0;
2644}
2645static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_true_v(void)
2646{
2647 return 0x00000001;
2648}
2649static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_true_f(void)
2650{
2651 return 0x80000000;
2652}
2653static inline u32 gr_gpc0_swdx_rm_spill_buffer_size_r(void)
2654{
2655 return 0x005001dc;
2656}
2657static inline u32 gr_gpc0_swdx_rm_spill_buffer_size_256b_f(u32 v)
2658{
2659 return (v & 0xffff) << 0;
2660}
2661static inline u32 gr_gpc0_swdx_rm_spill_buffer_size_256b_default_v(void)
2662{
2663 return 0x00000de0;
2664}
2665static inline u32 gr_gpc0_swdx_rm_spill_buffer_size_256b_byte_granularity_v(void)
2666{
2667 return 0x00000100;
2668}
2669static inline u32 gr_gpc0_swdx_rm_spill_buffer_addr_r(void)
2670{
2671 return 0x005001d8;
2672}
2673static inline u32 gr_gpc0_swdx_rm_spill_buffer_addr_39_8_f(u32 v)
2674{
2675 return (v & 0xffffffff) << 0;
2676}
2677static inline u32 gr_gpc0_swdx_rm_spill_buffer_addr_39_8_align_bits_v(void)
2678{
2679 return 0x00000008;
2680}
2681static inline u32 gr_gpcs_swdx_beta_cb_ctrl_r(void)
2682{
2683 return 0x004181e4;
2684}
2685static inline u32 gr_gpcs_swdx_beta_cb_ctrl_cbes_reserve_f(u32 v)
2686{
2687 return (v & 0xfff) << 0;
2688}
2689static inline u32 gr_gpcs_swdx_beta_cb_ctrl_cbes_reserve_gfxp_v(void)
2690{
2691 return 0x00000100;
2692}
2693static inline u32 gr_gpcs_ppcs_cbm_beta_cb_ctrl_r(void)
2694{
2695 return 0x0041befc;
2696}
2697static inline u32 gr_gpcs_ppcs_cbm_beta_cb_ctrl_cbes_reserve_f(u32 v)
2698{
2699 return (v & 0xfff) << 0;
2700}
2701static inline u32 gr_gpcs_swdx_tc_beta_cb_size_r(u32 i)
2702{
2703 return 0x00418ea0 + i*4;
2704}
2705static inline u32 gr_gpcs_swdx_tc_beta_cb_size_v_f(u32 v)
2706{
2707 return (v & 0x3fffff) << 0;
2708}
2709static inline u32 gr_gpcs_swdx_tc_beta_cb_size_v_m(void)
2710{
2711 return 0x3fffff << 0;
2712}
2713static inline u32 gr_gpcs_swdx_dss_zbc_color_r_r(u32 i)
2714{
2715 return 0x00418010 + i*4;
2716}
2717static inline u32 gr_gpcs_swdx_dss_zbc_color_r_val_f(u32 v)
2718{
2719 return (v & 0xffffffff) << 0;
2720}
2721static inline u32 gr_gpcs_swdx_dss_zbc_color_g_r(u32 i)
2722{
2723 return 0x0041804c + i*4;
2724}
2725static inline u32 gr_gpcs_swdx_dss_zbc_color_g_val_f(u32 v)
2726{
2727 return (v & 0xffffffff) << 0;
2728}
2729static inline u32 gr_gpcs_swdx_dss_zbc_color_b_r(u32 i)
2730{
2731 return 0x00418088 + i*4;
2732}
2733static inline u32 gr_gpcs_swdx_dss_zbc_color_b_val_f(u32 v)
2734{
2735 return (v & 0xffffffff) << 0;
2736}
2737static inline u32 gr_gpcs_swdx_dss_zbc_color_a_r(u32 i)
2738{
2739 return 0x004180c4 + i*4;
2740}
2741static inline u32 gr_gpcs_swdx_dss_zbc_color_a_val_f(u32 v)
2742{
2743 return (v & 0xffffffff) << 0;
2744}
2745static inline u32 gr_gpcs_swdx_dss_zbc_c_01_to_04_format_r(void)
2746{
2747 return 0x00500100;
2748}
2749static inline u32 gr_gpcs_swdx_dss_zbc_z_r(u32 i)
2750{
2751 return 0x00418110 + i*4;
2752}
2753static inline u32 gr_gpcs_swdx_dss_zbc_z_val_f(u32 v)
2754{
2755 return (v & 0xffffffff) << 0;
2756}
2757static inline u32 gr_gpcs_swdx_dss_zbc_z_01_to_04_format_r(void)
2758{
2759 return 0x0050014c;
2760}
2761static inline u32 gr_gpcs_setup_attrib_cb_base_r(void)
2762{
2763 return 0x00418810;
2764}
2765static inline u32 gr_gpcs_setup_attrib_cb_base_addr_39_12_f(u32 v)
2766{
2767 return (v & 0xfffffff) << 0;
2768}
2769static inline u32 gr_gpcs_setup_attrib_cb_base_addr_39_12_align_bits_v(void)
2770{
2771 return 0x0000000c;
2772}
2773static inline u32 gr_gpcs_setup_attrib_cb_base_valid_true_f(void)
2774{
2775 return 0x80000000;
2776}
2777static inline u32 gr_crstr_gpc_map0_r(void)
2778{
2779 return 0x00418b08;
2780}
2781static inline u32 gr_crstr_gpc_map0_tile0_f(u32 v)
2782{
2783 return (v & 0x7) << 0;
2784}
2785static inline u32 gr_crstr_gpc_map0_tile1_f(u32 v)
2786{
2787 return (v & 0x7) << 5;
2788}
2789static inline u32 gr_crstr_gpc_map0_tile2_f(u32 v)
2790{
2791 return (v & 0x7) << 10;
2792}
2793static inline u32 gr_crstr_gpc_map0_tile3_f(u32 v)
2794{
2795 return (v & 0x7) << 15;
2796}
2797static inline u32 gr_crstr_gpc_map0_tile4_f(u32 v)
2798{
2799 return (v & 0x7) << 20;
2800}
2801static inline u32 gr_crstr_gpc_map0_tile5_f(u32 v)
2802{
2803 return (v & 0x7) << 25;
2804}
2805static inline u32 gr_crstr_gpc_map1_r(void)
2806{
2807 return 0x00418b0c;
2808}
2809static inline u32 gr_crstr_gpc_map1_tile6_f(u32 v)
2810{
2811 return (v & 0x7) << 0;
2812}
2813static inline u32 gr_crstr_gpc_map1_tile7_f(u32 v)
2814{
2815 return (v & 0x7) << 5;
2816}
2817static inline u32 gr_crstr_gpc_map1_tile8_f(u32 v)
2818{
2819 return (v & 0x7) << 10;
2820}
2821static inline u32 gr_crstr_gpc_map1_tile9_f(u32 v)
2822{
2823 return (v & 0x7) << 15;
2824}
2825static inline u32 gr_crstr_gpc_map1_tile10_f(u32 v)
2826{
2827 return (v & 0x7) << 20;
2828}
2829static inline u32 gr_crstr_gpc_map1_tile11_f(u32 v)
2830{
2831 return (v & 0x7) << 25;
2832}
2833static inline u32 gr_crstr_gpc_map2_r(void)
2834{
2835 return 0x00418b10;
2836}
2837static inline u32 gr_crstr_gpc_map2_tile12_f(u32 v)
2838{
2839 return (v & 0x7) << 0;
2840}
2841static inline u32 gr_crstr_gpc_map2_tile13_f(u32 v)
2842{
2843 return (v & 0x7) << 5;
2844}
2845static inline u32 gr_crstr_gpc_map2_tile14_f(u32 v)
2846{
2847 return (v & 0x7) << 10;
2848}
2849static inline u32 gr_crstr_gpc_map2_tile15_f(u32 v)
2850{
2851 return (v & 0x7) << 15;
2852}
2853static inline u32 gr_crstr_gpc_map2_tile16_f(u32 v)
2854{
2855 return (v & 0x7) << 20;
2856}
2857static inline u32 gr_crstr_gpc_map2_tile17_f(u32 v)
2858{
2859 return (v & 0x7) << 25;
2860}
2861static inline u32 gr_crstr_gpc_map3_r(void)
2862{
2863 return 0x00418b14;
2864}
2865static inline u32 gr_crstr_gpc_map3_tile18_f(u32 v)
2866{
2867 return (v & 0x7) << 0;
2868}
2869static inline u32 gr_crstr_gpc_map3_tile19_f(u32 v)
2870{
2871 return (v & 0x7) << 5;
2872}
2873static inline u32 gr_crstr_gpc_map3_tile20_f(u32 v)
2874{
2875 return (v & 0x7) << 10;
2876}
2877static inline u32 gr_crstr_gpc_map3_tile21_f(u32 v)
2878{
2879 return (v & 0x7) << 15;
2880}
2881static inline u32 gr_crstr_gpc_map3_tile22_f(u32 v)
2882{
2883 return (v & 0x7) << 20;
2884}
2885static inline u32 gr_crstr_gpc_map3_tile23_f(u32 v)
2886{
2887 return (v & 0x7) << 25;
2888}
2889static inline u32 gr_crstr_gpc_map4_r(void)
2890{
2891 return 0x00418b18;
2892}
2893static inline u32 gr_crstr_gpc_map4_tile24_f(u32 v)
2894{
2895 return (v & 0x7) << 0;
2896}
2897static inline u32 gr_crstr_gpc_map4_tile25_f(u32 v)
2898{
2899 return (v & 0x7) << 5;
2900}
2901static inline u32 gr_crstr_gpc_map4_tile26_f(u32 v)
2902{
2903 return (v & 0x7) << 10;
2904}
2905static inline u32 gr_crstr_gpc_map4_tile27_f(u32 v)
2906{
2907 return (v & 0x7) << 15;
2908}
2909static inline u32 gr_crstr_gpc_map4_tile28_f(u32 v)
2910{
2911 return (v & 0x7) << 20;
2912}
2913static inline u32 gr_crstr_gpc_map4_tile29_f(u32 v)
2914{
2915 return (v & 0x7) << 25;
2916}
2917static inline u32 gr_crstr_gpc_map5_r(void)
2918{
2919 return 0x00418b1c;
2920}
2921static inline u32 gr_crstr_gpc_map5_tile30_f(u32 v)
2922{
2923 return (v & 0x7) << 0;
2924}
2925static inline u32 gr_crstr_gpc_map5_tile31_f(u32 v)
2926{
2927 return (v & 0x7) << 5;
2928}
2929static inline u32 gr_crstr_gpc_map5_tile32_f(u32 v)
2930{
2931 return (v & 0x7) << 10;
2932}
2933static inline u32 gr_crstr_gpc_map5_tile33_f(u32 v)
2934{
2935 return (v & 0x7) << 15;
2936}
2937static inline u32 gr_crstr_gpc_map5_tile34_f(u32 v)
2938{
2939 return (v & 0x7) << 20;
2940}
2941static inline u32 gr_crstr_gpc_map5_tile35_f(u32 v)
2942{
2943 return (v & 0x7) << 25;
2944}
2945static inline u32 gr_crstr_map_table_cfg_r(void)
2946{
2947 return 0x00418bb8;
2948}
2949static inline u32 gr_crstr_map_table_cfg_row_offset_f(u32 v)
2950{
2951 return (v & 0xff) << 0;
2952}
2953static inline u32 gr_crstr_map_table_cfg_num_entries_f(u32 v)
2954{
2955 return (v & 0xff) << 8;
2956}
2957static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_r(void)
2958{
2959 return 0x00418980;
2960}
2961static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_0_f(u32 v)
2962{
2963 return (v & 0x7) << 0;
2964}
2965static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_1_f(u32 v)
2966{
2967 return (v & 0x7) << 4;
2968}
2969static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_2_f(u32 v)
2970{
2971 return (v & 0x7) << 8;
2972}
2973static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_3_f(u32 v)
2974{
2975 return (v & 0x7) << 12;
2976}
2977static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_4_f(u32 v)
2978{
2979 return (v & 0x7) << 16;
2980}
2981static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_5_f(u32 v)
2982{
2983 return (v & 0x7) << 20;
2984}
2985static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_6_f(u32 v)
2986{
2987 return (v & 0x7) << 24;
2988}
2989static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_7_f(u32 v)
2990{
2991 return (v & 0x7) << 28;
2992}
2993static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_r(void)
2994{
2995 return 0x00418984;
2996}
2997static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_8_f(u32 v)
2998{
2999 return (v & 0x7) << 0;
3000}
3001static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_9_f(u32 v)
3002{
3003 return (v & 0x7) << 4;
3004}
3005static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_10_f(u32 v)
3006{
3007 return (v & 0x7) << 8;
3008}
3009static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_11_f(u32 v)
3010{
3011 return (v & 0x7) << 12;
3012}
3013static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_12_f(u32 v)
3014{
3015 return (v & 0x7) << 16;
3016}
3017static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_13_f(u32 v)
3018{
3019 return (v & 0x7) << 20;
3020}
3021static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_14_f(u32 v)
3022{
3023 return (v & 0x7) << 24;
3024}
3025static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_15_f(u32 v)
3026{
3027 return (v & 0x7) << 28;
3028}
3029static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_r(void)
3030{
3031 return 0x00418988;
3032}
3033static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_16_f(u32 v)
3034{
3035 return (v & 0x7) << 0;
3036}
3037static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_17_f(u32 v)
3038{
3039 return (v & 0x7) << 4;
3040}
3041static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_18_f(u32 v)
3042{
3043 return (v & 0x7) << 8;
3044}
3045static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_19_f(u32 v)
3046{
3047 return (v & 0x7) << 12;
3048}
3049static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_20_f(u32 v)
3050{
3051 return (v & 0x7) << 16;
3052}
3053static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_21_f(u32 v)
3054{
3055 return (v & 0x7) << 20;
3056}
3057static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_22_f(u32 v)
3058{
3059 return (v & 0x7) << 24;
3060}
3061static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_23_s(void)
3062{
3063 return 3;
3064}
3065static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_23_f(u32 v)
3066{
3067 return (v & 0x7) << 28;
3068}
3069static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_23_m(void)
3070{
3071 return 0x7 << 28;
3072}
3073static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_23_v(u32 r)
3074{
3075 return (r >> 28) & 0x7;
3076}
3077static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_r(void)
3078{
3079 return 0x0041898c;
3080}
3081static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_24_f(u32 v)
3082{
3083 return (v & 0x7) << 0;
3084}
3085static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_25_f(u32 v)
3086{
3087 return (v & 0x7) << 4;
3088}
3089static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_26_f(u32 v)
3090{
3091 return (v & 0x7) << 8;
3092}
3093static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_27_f(u32 v)
3094{
3095 return (v & 0x7) << 12;
3096}
3097static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_28_f(u32 v)
3098{
3099 return (v & 0x7) << 16;
3100}
3101static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_29_f(u32 v)
3102{
3103 return (v & 0x7) << 20;
3104}
3105static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_30_f(u32 v)
3106{
3107 return (v & 0x7) << 24;
3108}
3109static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_31_f(u32 v)
3110{
3111 return (v & 0x7) << 28;
3112}
3113static inline u32 gr_gpcs_gpm_pd_cfg_r(void)
3114{
3115 return 0x00418c6c;
3116}
3117static inline u32 gr_gpcs_gpm_pd_cfg_timeslice_mode_disable_f(void)
3118{
3119 return 0x0;
3120}
3121static inline u32 gr_gpcs_gpm_pd_cfg_timeslice_mode_enable_f(void)
3122{
3123 return 0x1;
3124}
3125static inline u32 gr_gpcs_gcc_pagepool_base_r(void)
3126{
3127 return 0x00419004;
3128}
3129static inline u32 gr_gpcs_gcc_pagepool_base_addr_39_8_f(u32 v)
3130{
3131 return (v & 0xffffffff) << 0;
3132}
3133static inline u32 gr_gpcs_gcc_pagepool_r(void)
3134{
3135 return 0x00419008;
3136}
3137static inline u32 gr_gpcs_gcc_pagepool_total_pages_f(u32 v)
3138{
3139 return (v & 0x3ff) << 0;
3140}
3141static inline u32 gr_gpcs_tpcs_pe_vaf_r(void)
3142{
3143 return 0x0041980c;
3144}
3145static inline u32 gr_gpcs_tpcs_pe_vaf_fast_mode_switch_true_f(void)
3146{
3147 return 0x10;
3148}
3149static inline u32 gr_gpcs_tpcs_pe_pin_cb_global_base_addr_r(void)
3150{
3151 return 0x00419848;
3152}
3153static inline u32 gr_gpcs_tpcs_pe_pin_cb_global_base_addr_v_f(u32 v)
3154{
3155 return (v & 0xfffffff) << 0;
3156}
3157static inline u32 gr_gpcs_tpcs_pe_pin_cb_global_base_addr_valid_f(u32 v)
3158{
3159 return (v & 0x1) << 28;
3160}
3161static inline u32 gr_gpcs_tpcs_pe_pin_cb_global_base_addr_valid_true_f(void)
3162{
3163 return 0x10000000;
3164}
3165static inline u32 gr_gpcs_tpcs_mpc_vtg_debug_r(void)
3166{
3167 return 0x00419c00;
3168}
3169static inline u32 gr_gpcs_tpcs_mpc_vtg_debug_timeslice_mode_disabled_f(void)
3170{
3171 return 0x0;
3172}
3173static inline u32 gr_gpcs_tpcs_mpc_vtg_debug_timeslice_mode_enabled_f(void)
3174{
3175 return 0x8;
3176}
3177static inline u32 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_r(void)
3178{
3179 return 0x00419c2c;
3180}
3181static inline u32 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_v_f(u32 v)
3182{
3183 return (v & 0xfffffff) << 0;
3184}
3185static inline u32 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_valid_f(u32 v)
3186{
3187 return (v & 0x1) << 28;
3188}
3189static inline u32 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_valid_true_f(void)
3190{
3191 return 0x10000000;
3192}
3193static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_r(void)
3194{
3195 return 0x00419e44;
3196}
3197static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_stack_error_report_f(void)
3198{
3199 return 0x2;
3200}
3201static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_api_stack_error_report_f(void)
3202{
3203 return 0x4;
3204}
3205static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_ret_empty_stack_error_report_f(void)
3206{
3207 return 0x8;
3208}
3209static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_pc_wrap_report_f(void)
3210{
3211 return 0x10;
3212}
3213static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_misaligned_pc_report_f(void)
3214{
3215 return 0x20;
3216}
3217static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_pc_overflow_report_f(void)
3218{
3219 return 0x40;
3220}
3221static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_misaligned_immc_addr_report_f(void)
3222{
3223 return 0x80;
3224}
3225static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_misaligned_reg_report_f(void)
3226{
3227 return 0x100;
3228}
3229static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_illegal_instr_encoding_report_f(void)
3230{
3231 return 0x200;
3232}
3233static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_illegal_sph_instr_combo_report_f(void)
3234{
3235 return 0x400;
3236}
3237static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_illegal_instr_param_report_f(void)
3238{
3239 return 0x800;
3240}
3241static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_invalid_const_addr_report_f(void)
3242{
3243 return 0x1000;
3244}
3245static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_oor_reg_report_f(void)
3246{
3247 return 0x2000;
3248}
3249static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_oor_addr_report_f(void)
3250{
3251 return 0x4000;
3252}
3253static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_misaligned_addr_report_f(void)
3254{
3255 return 0x8000;
3256}
3257static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_invalid_addr_space_report_f(void)
3258{
3259 return 0x10000;
3260}
3261static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_illegal_instr_param2_report_f(void)
3262{
3263 return 0x20000;
3264}
3265static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_invalid_const_addr_ldc_report_f(void)
3266{
3267 return 0x40000;
3268}
3269static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_mmu_fault_report_f(void)
3270{
3271 return 0x800000;
3272}
3273static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_stack_overflow_report_f(void)
3274{
3275 return 0x400000;
3276}
3277static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_geometry_sm_error_report_f(void)
3278{
3279 return 0x80000;
3280}
3281static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_divergent_report_f(void)
3282{
3283 return 0x100000;
3284}
3285static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_r(void)
3286{
3287 return 0x00419e4c;
3288}
3289static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_sm_to_sm_fault_report_f(void)
3290{
3291 return 0x1;
3292}
3293static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_l1_error_report_f(void)
3294{
3295 return 0x2;
3296}
3297static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_multiple_warp_errors_report_f(void)
3298{
3299 return 0x4;
3300}
3301static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_physical_stack_overflow_error_report_f(void)
3302{
3303 return 0x8;
3304}
3305static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_bpt_int_report_f(void)
3306{
3307 return 0x10;
3308}
3309static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_ecc_sec_error_report_f(void)
3310{
3311 return 0x20000000;
3312}
3313static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_ecc_ded_error_report_f(void)
3314{
3315 return 0x40000000;
3316}
3317static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_bpt_pause_report_f(void)
3318{
3319 return 0x20;
3320}
3321static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_single_step_complete_report_f(void)
3322{
3323 return 0x40;
3324}
3325static inline u32 gr_gpcs_tpcs_tpccs_tpc_exception_en_r(void)
3326{
3327 return 0x00419d0c;
3328}
3329static inline u32 gr_gpcs_tpcs_tpccs_tpc_exception_en_sm_enabled_f(void)
3330{
3331 return 0x2;
3332}
3333static inline u32 gr_gpcs_tpcs_tpccs_tpc_exception_en_tex_enabled_f(void)
3334{
3335 return 0x1;
3336}
3337static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_en_r(void)
3338{
3339 return 0x0050450c;
3340}
3341static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_en_sm_v(u32 r)
3342{
3343 return (r >> 1) & 0x1;
3344}
3345static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_en_sm_enabled_f(void)
3346{
3347 return 0x2;
3348}
3349static inline u32 gr_gpcs_gpccs_gpc_exception_en_r(void)
3350{
3351 return 0x0041ac94;
3352}
3353static inline u32 gr_gpcs_gpccs_gpc_exception_en_tpc_f(u32 v)
3354{
3355 return (v & 0xff) << 16;
3356}
3357static inline u32 gr_gpc0_gpccs_gpc_exception_r(void)
3358{
3359 return 0x00502c90;
3360}
3361static inline u32 gr_gpc0_gpccs_gpc_exception_tpc_v(u32 r)
3362{
3363 return (r >> 16) & 0xff;
3364}
3365static inline u32 gr_gpc0_gpccs_gpc_exception_tpc_0_pending_v(void)
3366{
3367 return 0x00000001;
3368}
3369static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_r(void)
3370{
3371 return 0x00504508;
3372}
3373static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_tex_v(u32 r)
3374{
3375 return (r >> 0) & 0x1;
3376}
3377static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_tex_pending_v(void)
3378{
3379 return 0x00000001;
3380}
3381static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_sm_v(u32 r)
3382{
3383 return (r >> 1) & 0x1;
3384}
3385static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_sm_pending_v(void)
3386{
3387 return 0x00000001;
3388}
3389static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_r(void)
3390{
3391 return 0x00504610;
3392}
3393static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_m(void)
3394{
3395 return 0x1 << 0;
3396}
3397static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_v(u32 r)
3398{
3399 return (r >> 0) & 0x1;
3400}
3401static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_on_v(void)
3402{
3403 return 0x00000001;
3404}
3405static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_on_f(void)
3406{
3407 return 0x1;
3408}
3409static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_off_v(void)
3410{
3411 return 0x00000000;
3412}
3413static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_off_f(void)
3414{
3415 return 0x0;
3416}
3417static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_trigger_enable_f(void)
3418{
3419 return 0x80000000;
3420}
3421static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_trigger_disable_f(void)
3422{
3423 return 0x0;
3424}
3425static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_run_trigger_task_f(void)
3426{
3427 return 0x40000000;
3428}
3429static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_warp_m(void)
3430{
3431 return 0x1 << 1;
3432}
3433static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_warp_v(u32 r)
3434{
3435 return (r >> 1) & 0x1;
3436}
3437static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_warp_disable_f(void)
3438{
3439 return 0x0;
3440}
3441static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_sm_m(void)
3442{
3443 return 0x1 << 2;
3444}
3445static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_sm_v(u32 r)
3446{
3447 return (r >> 2) & 0x1;
3448}
3449static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_sm_disable_f(void)
3450{
3451 return 0x0;
3452}
3453static inline u32 gr_gpc0_tpc0_sm_warp_valid_mask_r(void)
3454{
3455 return 0x00504614;
3456}
3457static inline u32 gr_gpc0_tpc0_sm_dbgr_bpt_pause_mask_r(void)
3458{
3459 return 0x00504624;
3460}
3461static inline u32 gr_gpc0_tpc0_sm_dbgr_bpt_trap_mask_r(void)
3462{
3463 return 0x00504634;
3464}
3465static inline u32 gr_gpcs_tpcs_sm_dbgr_bpt_pause_mask_r(void)
3466{
3467 return 0x00419e24;
3468}
3469static inline u32 gr_gpcs_tpcs_sm_dbgr_bpt_pause_mask_stop_on_any_warp_disable_v(void)
3470{
3471 return 0x00000000;
3472}
3473static inline u32 gr_gpcs_tpcs_sm_dbgr_bpt_pause_mask_stop_on_any_sm_disable_v(void)
3474{
3475 return 0x00000000;
3476}
3477static inline u32 gr_gpc0_tpc0_sm_dbgr_status0_r(void)
3478{
3479 return 0x0050460c;
3480}
3481static inline u32 gr_gpc0_tpc0_sm_dbgr_status0_sm_in_trap_mode_v(u32 r)
3482{
3483 return (r >> 0) & 0x1;
3484}
3485static inline u32 gr_gpc0_tpc0_sm_dbgr_status0_locked_down_v(u32 r)
3486{
3487 return (r >> 4) & 0x1;
3488}
3489static inline u32 gr_gpc0_tpc0_sm_dbgr_status0_locked_down_true_v(void)
3490{
3491 return 0x00000001;
3492}
3493static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_r(void)
3494{
3495 return 0x00419e50;
3496}
3497static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_bpt_int_pending_f(void)
3498{
3499 return 0x10;
3500}
3501static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_bpt_pause_pending_f(void)
3502{
3503 return 0x20;
3504}
3505static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_single_step_complete_pending_f(void)
3506{
3507 return 0x40;
3508}
3509static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_r(void)
3510{
3511 return 0x00504650;
3512}
3513static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_bpt_int_pending_f(void)
3514{
3515 return 0x10;
3516}
3517static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_ecc_sec_error_pending_f(void)
3518{
3519 return 0x20000000;
3520}
3521static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_ecc_ded_error_pending_f(void)
3522{
3523 return 0x40000000;
3524}
3525static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_bpt_pause_pending_f(void)
3526{
3527 return 0x20;
3528}
3529static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_single_step_complete_pending_f(void)
3530{
3531 return 0x40;
3532}
3533static inline u32 gr_gpc0_tpc0_tex_m_hww_esr_r(void)
3534{
3535 return 0x00504224;
3536}
3537static inline u32 gr_gpc0_tpc0_tex_m_hww_esr_intr_pending_f(void)
3538{
3539 return 0x1;
3540}
3541static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_r(void)
3542{
3543 return 0x00504648;
3544}
3545static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_error_v(u32 r)
3546{
3547 return (r >> 0) & 0xffff;
3548}
3549static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_error_none_v(void)
3550{
3551 return 0x00000000;
3552}
3553static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_error_none_f(void)
3554{
3555 return 0x0;
3556}
3557static inline u32 gr_gpc0_tpc0_sm_halfctl_ctrl_r(void)
3558{
3559 return 0x00504770;
3560}
3561static inline u32 gr_gpcs_tpcs_sm_halfctl_ctrl_r(void)
3562{
3563 return 0x00419f70;
3564}
3565static inline u32 gr_gpcs_tpcs_sm_halfctl_ctrl_sctl_read_quad_ctl_m(void)
3566{
3567 return 0x1 << 4;
3568}
3569static inline u32 gr_gpcs_tpcs_sm_halfctl_ctrl_sctl_read_quad_ctl_f(u32 v)
3570{
3571 return (v & 0x1) << 4;
3572}
3573static inline u32 gr_gpc0_tpc0_sm_debug_sfe_control_r(void)
3574{
3575 return 0x0050477c;
3576}
3577static inline u32 gr_gpcs_tpcs_sm_debug_sfe_control_r(void)
3578{
3579 return 0x00419f7c;
3580}
3581static inline u32 gr_gpcs_tpcs_sm_debug_sfe_control_read_half_ctl_m(void)
3582{
3583 return 0x1 << 0;
3584}
3585static inline u32 gr_gpcs_tpcs_sm_debug_sfe_control_read_half_ctl_f(u32 v)
3586{
3587 return (v & 0x1) << 0;
3588}
3589static inline u32 gr_gpcs_tpcs_pes_vsc_vpc_r(void)
3590{
3591 return 0x0041be08;
3592}
3593static inline u32 gr_gpcs_tpcs_pes_vsc_vpc_fast_mode_switch_true_f(void)
3594{
3595 return 0x4;
3596}
3597static inline u32 gr_ppcs_wwdx_map_gpc_map0_r(void)
3598{
3599 return 0x0041bf00;
3600}
3601static inline u32 gr_ppcs_wwdx_map_gpc_map1_r(void)
3602{
3603 return 0x0041bf04;
3604}
3605static inline u32 gr_ppcs_wwdx_map_gpc_map2_r(void)
3606{
3607 return 0x0041bf08;
3608}
3609static inline u32 gr_ppcs_wwdx_map_gpc_map3_r(void)
3610{
3611 return 0x0041bf0c;
3612}
3613static inline u32 gr_ppcs_wwdx_map_gpc_map4_r(void)
3614{
3615 return 0x0041bf10;
3616}
3617static inline u32 gr_ppcs_wwdx_map_gpc_map5_r(void)
3618{
3619 return 0x0041bf14;
3620}
3621static inline u32 gr_ppcs_wwdx_map_table_cfg_r(void)
3622{
3623 return 0x0041bfd0;
3624}
3625static inline u32 gr_ppcs_wwdx_map_table_cfg_row_offset_f(u32 v)
3626{
3627 return (v & 0xff) << 0;
3628}
3629static inline u32 gr_ppcs_wwdx_map_table_cfg_num_entries_f(u32 v)
3630{
3631 return (v & 0xff) << 8;
3632}
3633static inline u32 gr_ppcs_wwdx_map_table_cfg_normalized_num_entries_f(u32 v)
3634{
3635 return (v & 0x1f) << 16;
3636}
3637static inline u32 gr_ppcs_wwdx_map_table_cfg_normalized_shift_value_f(u32 v)
3638{
3639 return (v & 0x7) << 21;
3640}
3641static inline u32 gr_ppcs_wwdx_map_table_cfg_coeff5_mod_value_f(u32 v)
3642{
3643 return (v & 0x1f) << 24;
3644}
3645static inline u32 gr_gpcs_ppcs_wwdx_sm_num_rcp_r(void)
3646{
3647 return 0x0041bfd4;
3648}
3649static inline u32 gr_gpcs_ppcs_wwdx_sm_num_rcp_conservative_f(u32 v)
3650{
3651 return (v & 0xffffff) << 0;
3652}
3653static inline u32 gr_ppcs_wwdx_map_table_cfg2_r(void)
3654{
3655 return 0x0041bfe4;
3656}
3657static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff6_mod_value_f(u32 v)
3658{
3659 return (v & 0x1f) << 0;
3660}
3661static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff7_mod_value_f(u32 v)
3662{
3663 return (v & 0x1f) << 5;
3664}
3665static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff8_mod_value_f(u32 v)
3666{
3667 return (v & 0x1f) << 10;
3668}
3669static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff9_mod_value_f(u32 v)
3670{
3671 return (v & 0x1f) << 15;
3672}
3673static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff10_mod_value_f(u32 v)
3674{
3675 return (v & 0x1f) << 20;
3676}
3677static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff11_mod_value_f(u32 v)
3678{
3679 return (v & 0x1f) << 25;
3680}
3681static inline u32 gr_bes_zrop_settings_r(void)
3682{
3683 return 0x00408850;
3684}
3685static inline u32 gr_bes_zrop_settings_num_active_ltcs_f(u32 v)
3686{
3687 return (v & 0xf) << 0;
3688}
3689static inline u32 gr_be0_crop_debug3_r(void)
3690{
3691 return 0x00410108;
3692}
3693static inline u32 gr_bes_crop_debug3_r(void)
3694{
3695 return 0x00408908;
3696}
3697static inline u32 gr_bes_crop_debug3_comp_vdc_4to2_disable_m(void)
3698{
3699 return 0x1 << 31;
3700}
3701static inline u32 gr_bes_crop_settings_r(void)
3702{
3703 return 0x00408958;
3704}
3705static inline u32 gr_bes_crop_settings_num_active_ltcs_f(u32 v)
3706{
3707 return (v & 0xf) << 0;
3708}
3709static inline u32 gr_zcull_bytes_per_aliquot_per_gpu_v(void)
3710{
3711 return 0x00000020;
3712}
3713static inline u32 gr_zcull_save_restore_header_bytes_per_gpc_v(void)
3714{
3715 return 0x00000020;
3716}
3717static inline u32 gr_zcull_save_restore_subregion_header_bytes_per_gpc_v(void)
3718{
3719 return 0x000000c0;
3720}
3721static inline u32 gr_zcull_subregion_qty_v(void)
3722{
3723 return 0x00000010;
3724}
3725static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control_sel0_r(void)
3726{
3727 return 0x00504604;
3728}
3729static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control_sel1_r(void)
3730{
3731 return 0x00504608;
3732}
3733static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control0_r(void)
3734{
3735 return 0x0050465c;
3736}
3737static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control1_r(void)
3738{
3739 return 0x00504660;
3740}
3741static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control2_r(void)
3742{
3743 return 0x00504664;
3744}
3745static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control3_r(void)
3746{
3747 return 0x00504668;
3748}
3749static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control4_r(void)
3750{
3751 return 0x0050466c;
3752}
3753static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control5_r(void)
3754{
3755 return 0x00504658;
3756}
3757static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter0_control_r(void)
3758{
3759 return 0x00504730;
3760}
3761static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter1_control_r(void)
3762{
3763 return 0x00504734;
3764}
3765static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter2_control_r(void)
3766{
3767 return 0x00504738;
3768}
3769static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter3_control_r(void)
3770{
3771 return 0x0050473c;
3772}
3773static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter4_control_r(void)
3774{
3775 return 0x00504740;
3776}
3777static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter5_control_r(void)
3778{
3779 return 0x00504744;
3780}
3781static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter6_control_r(void)
3782{
3783 return 0x00504748;
3784}
3785static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter7_control_r(void)
3786{
3787 return 0x0050474c;
3788}
3789static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_status_s1_r(void)
3790{
3791 return 0x00504678;
3792}
3793static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_status1_r(void)
3794{
3795 return 0x00504694;
3796}
3797static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter0_s0_r(void)
3798{
3799 return 0x005046f0;
3800}
3801static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter0_s1_r(void)
3802{
3803 return 0x00504700;
3804}
3805static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter1_s0_r(void)
3806{
3807 return 0x005046f4;
3808}
3809static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter1_s1_r(void)
3810{
3811 return 0x00504704;
3812}
3813static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter2_s0_r(void)
3814{
3815 return 0x005046f8;
3816}
3817static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter2_s1_r(void)
3818{
3819 return 0x00504708;
3820}
3821static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter3_s0_r(void)
3822{
3823 return 0x005046fc;
3824}
3825static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter3_s1_r(void)
3826{
3827 return 0x0050470c;
3828}
3829static inline u32 gr_fe_pwr_mode_r(void)
3830{
3831 return 0x00404170;
3832}
3833static inline u32 gr_fe_pwr_mode_mode_auto_f(void)
3834{
3835 return 0x0;
3836}
3837static inline u32 gr_fe_pwr_mode_mode_force_on_f(void)
3838{
3839 return 0x2;
3840}
3841static inline u32 gr_fe_pwr_mode_req_v(u32 r)
3842{
3843 return (r >> 4) & 0x1;
3844}
3845static inline u32 gr_fe_pwr_mode_req_send_f(void)
3846{
3847 return 0x10;
3848}
3849static inline u32 gr_fe_pwr_mode_req_done_v(void)
3850{
3851 return 0x00000000;
3852}
3853static inline u32 gr_gpcs_pri_mmu_ctrl_r(void)
3854{
3855 return 0x00418880;
3856}
3857static inline u32 gr_gpcs_pri_mmu_ctrl_vm_pg_size_m(void)
3858{
3859 return 0x1 << 0;
3860}
3861static inline u32 gr_gpcs_pri_mmu_ctrl_use_pdb_big_page_size_m(void)
3862{
3863 return 0x1 << 11;
3864}
3865static inline u32 gr_gpcs_pri_mmu_ctrl_vol_fault_m(void)
3866{
3867 return 0x1 << 1;
3868}
3869static inline u32 gr_gpcs_pri_mmu_ctrl_comp_fault_m(void)
3870{
3871 return 0x1 << 2;
3872}
3873static inline u32 gr_gpcs_pri_mmu_ctrl_miss_gran_m(void)
3874{
3875 return 0x3 << 3;
3876}
3877static inline u32 gr_gpcs_pri_mmu_ctrl_cache_mode_m(void)
3878{
3879 return 0x3 << 5;
3880}
3881static inline u32 gr_gpcs_pri_mmu_ctrl_mmu_aperture_m(void)
3882{
3883 return 0x3 << 28;
3884}
3885static inline u32 gr_gpcs_pri_mmu_ctrl_mmu_vol_m(void)
3886{
3887 return 0x1 << 30;
3888}
3889static inline u32 gr_gpcs_pri_mmu_ctrl_mmu_disable_m(void)
3890{
3891 return 0x1 << 31;
3892}
3893static inline u32 gr_gpcs_pri_mmu_pm_unit_mask_r(void)
3894{
3895 return 0x00418890;
3896}
3897static inline u32 gr_gpcs_pri_mmu_pm_req_mask_r(void)
3898{
3899 return 0x00418894;
3900}
3901static inline u32 gr_gpcs_pri_mmu_debug_ctrl_r(void)
3902{
3903 return 0x004188b0;
3904}
3905static inline u32 gr_gpcs_pri_mmu_debug_ctrl_debug_v(u32 r)
3906{
3907 return (r >> 16) & 0x1;
3908}
3909static inline u32 gr_gpcs_pri_mmu_debug_ctrl_debug_enabled_v(void)
3910{
3911 return 0x00000001;
3912}
3913static inline u32 gr_gpcs_pri_mmu_debug_wr_r(void)
3914{
3915 return 0x004188b4;
3916}
3917static inline u32 gr_gpcs_pri_mmu_debug_rd_r(void)
3918{
3919 return 0x004188b8;
3920}
3921static inline u32 gr_gpcs_mmu_num_active_ltcs_r(void)
3922{
3923 return 0x004188ac;
3924}
3925static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_r(void)
3926{
3927 return 0x00419e10;
3928}
3929static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_debugger_mode_f(u32 v)
3930{
3931 return (v & 0x1) << 0;
3932}
3933static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_debugger_mode_on_v(void)
3934{
3935 return 0x00000001;
3936}
3937static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_stop_trigger_m(void)
3938{
3939 return 0x1 << 31;
3940}
3941static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_stop_trigger_v(u32 r)
3942{
3943 return (r >> 31) & 0x1;
3944}
3945static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_stop_trigger_enable_f(void)
3946{
3947 return 0x80000000;
3948}
3949static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_stop_trigger_disable_f(void)
3950{
3951 return 0x0;
3952}
3953static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_run_trigger_m(void)
3954{
3955 return 0x1 << 30;
3956}
3957static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_run_trigger_v(u32 r)
3958{
3959 return (r >> 30) & 0x1;
3960}
3961static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_run_trigger_task_f(void)
3962{
3963 return 0x40000000;
3964}
3965static inline u32 gr_fe_gfxp_wfi_timeout_r(void)
3966{
3967 return 0x004041c0;
3968}
3969static inline u32 gr_fe_gfxp_wfi_timeout_count_f(u32 v)
3970{
3971 return (v & 0xffffffff) << 0;
3972}
3973static inline u32 gr_fe_gfxp_wfi_timeout_count_disabled_f(void)
3974{
3975 return 0x0;
3976}
3977static inline u32 gr_gpcs_tpcs_sm_texio_control_r(void)
3978{
3979 return 0x00419c84;
3980}
3981static inline u32 gr_gpcs_tpcs_sm_texio_control_oor_addr_check_mode_f(u32 v)
3982{
3983 return (v & 0x7) << 8;
3984}
3985static inline u32 gr_gpcs_tpcs_sm_texio_control_oor_addr_check_mode_m(void)
3986{
3987 return 0x7 << 8;
3988}
3989static inline u32 gr_gpcs_tpcs_sm_texio_control_oor_addr_check_mode_arm_63_48_match_f(void)
3990{
3991 return 0x100;
3992}
3993static inline u32 gr_gpcs_tpcs_sm_disp_ctrl_r(void)
3994{
3995 return 0x00419f78;
3996}
3997static inline u32 gr_gpcs_tpcs_sm_disp_ctrl_re_suppress_m(void)
3998{
3999 return 0x3 << 11;
4000}
4001static inline u32 gr_gpcs_tpcs_sm_disp_ctrl_re_suppress_disable_f(void)
4002{
4003 return 0x1000;
4004}
4005static inline u32 gr_gpcs_tc_debug0_r(void)
4006{
4007 return 0x00418708;
4008}
4009static inline u32 gr_gpcs_tc_debug0_limit_coalesce_buffer_size_f(u32 v)
4010{
4011 return (v & 0x1ff) << 0;
4012}
4013static inline u32 gr_gpcs_tc_debug0_limit_coalesce_buffer_size_m(void)
4014{
4015 return 0x1ff << 0;
4016}
4017#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_ltc_gp106.h b/drivers/gpu/nvgpu/gp106/hw_ltc_gp106.h
new file mode 100644
index 00000000..d760b588
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_ltc_gp106.h
@@ -0,0 +1,553 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ltc_gp106_h_
51#define _hw_ltc_gp106_h_
52
53static inline u32 ltc_ltcs_lts0_cbc_ctrl1_r(void)
54{
55 return 0x0014046c;
56}
57static inline u32 ltc_ltc0_lts0_dstg_cfg0_r(void)
58{
59 return 0x00140518;
60}
61static inline u32 ltc_ltcs_ltss_dstg_cfg0_r(void)
62{
63 return 0x0017e318;
64}
65static inline u32 ltc_ltcs_ltss_dstg_cfg0_vdc_4to2_disable_m(void)
66{
67 return 0x1 << 15;
68}
69static inline u32 ltc_ltc0_lts0_tstg_cfg1_r(void)
70{
71 return 0x00140494;
72}
73static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_ways_v(u32 r)
74{
75 return (r >> 0) & 0xffff;
76}
77static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_sets_v(u32 r)
78{
79 return (r >> 16) & 0x3;
80}
81static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_sets_all_v(void)
82{
83 return 0x00000000;
84}
85static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_sets_half_v(void)
86{
87 return 0x00000001;
88}
89static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_sets_quarter_v(void)
90{
91 return 0x00000002;
92}
93static inline u32 ltc_ltcs_ltss_cbc_ctrl1_r(void)
94{
95 return 0x0017e26c;
96}
97static inline u32 ltc_ltcs_ltss_cbc_ctrl1_clean_active_f(void)
98{
99 return 0x1;
100}
101static inline u32 ltc_ltcs_ltss_cbc_ctrl1_invalidate_active_f(void)
102{
103 return 0x2;
104}
105static inline u32 ltc_ltcs_ltss_cbc_ctrl1_clear_v(u32 r)
106{
107 return (r >> 2) & 0x1;
108}
109static inline u32 ltc_ltcs_ltss_cbc_ctrl1_clear_active_v(void)
110{
111 return 0x00000001;
112}
113static inline u32 ltc_ltcs_ltss_cbc_ctrl1_clear_active_f(void)
114{
115 return 0x4;
116}
117static inline u32 ltc_ltc0_lts0_cbc_ctrl1_r(void)
118{
119 return 0x0014046c;
120}
121static inline u32 ltc_ltcs_ltss_cbc_ctrl2_r(void)
122{
123 return 0x0017e270;
124}
125static inline u32 ltc_ltcs_ltss_cbc_ctrl2_clear_lower_bound_f(u32 v)
126{
127 return (v & 0x3ffff) << 0;
128}
129static inline u32 ltc_ltcs_ltss_cbc_ctrl3_r(void)
130{
131 return 0x0017e274;
132}
133static inline u32 ltc_ltcs_ltss_cbc_ctrl3_clear_upper_bound_f(u32 v)
134{
135 return (v & 0x3ffff) << 0;
136}
137static inline u32 ltc_ltcs_ltss_cbc_ctrl3_clear_upper_bound_init_v(void)
138{
139 return 0x0003ffff;
140}
141static inline u32 ltc_ltcs_ltss_cbc_base_r(void)
142{
143 return 0x0017e278;
144}
145static inline u32 ltc_ltcs_ltss_cbc_base_alignment_shift_v(void)
146{
147 return 0x0000000b;
148}
149static inline u32 ltc_ltcs_ltss_cbc_base_address_v(u32 r)
150{
151 return (r >> 0) & 0x3ffffff;
152}
153static inline u32 ltc_ltcs_ltss_cbc_num_active_ltcs_r(void)
154{
155 return 0x0017e27c;
156}
157static inline u32 ltc_ltcs_misc_ltc_num_active_ltcs_r(void)
158{
159 return 0x0017e000;
160}
161static inline u32 ltc_ltcs_ltss_cbc_param_r(void)
162{
163 return 0x0017e280;
164}
165static inline u32 ltc_ltcs_ltss_cbc_param_comptags_per_cache_line_v(u32 r)
166{
167 return (r >> 0) & 0xffff;
168}
169static inline u32 ltc_ltcs_ltss_cbc_param_cache_line_size_v(u32 r)
170{
171 return (r >> 24) & 0xf;
172}
173static inline u32 ltc_ltcs_ltss_cbc_param_slices_per_ltc_v(u32 r)
174{
175 return (r >> 28) & 0xf;
176}
177static inline u32 ltc_ltcs_ltss_cbc_param2_r(void)
178{
179 return 0x0017e3f4;
180}
181static inline u32 ltc_ltcs_ltss_cbc_param2_gobs_per_comptagline_per_slice_v(u32 r)
182{
183 return (r >> 0) & 0xffff;
184}
185static inline u32 ltc_ltcs_ltss_tstg_set_mgmt_r(void)
186{
187 return 0x0017e2ac;
188}
189static inline u32 ltc_ltcs_ltss_tstg_set_mgmt_max_ways_evict_last_f(u32 v)
190{
191 return (v & 0x1f) << 16;
192}
193static inline u32 ltc_ltcs_ltss_dstg_zbc_index_r(void)
194{
195 return 0x0017e338;
196}
197static inline u32 ltc_ltcs_ltss_dstg_zbc_index_address_f(u32 v)
198{
199 return (v & 0xf) << 0;
200}
201static inline u32 ltc_ltcs_ltss_dstg_zbc_color_clear_value_r(u32 i)
202{
203 return 0x0017e33c + i*4;
204}
205static inline u32 ltc_ltcs_ltss_dstg_zbc_color_clear_value__size_1_v(void)
206{
207 return 0x00000004;
208}
209static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_r(void)
210{
211 return 0x0017e34c;
212}
213static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_field_s(void)
214{
215 return 32;
216}
217static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_field_f(u32 v)
218{
219 return (v & 0xffffffff) << 0;
220}
221static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_field_m(void)
222{
223 return 0xffffffff << 0;
224}
225static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_field_v(u32 r)
226{
227 return (r >> 0) & 0xffffffff;
228}
229static inline u32 ltc_ltcs_ltss_tstg_set_mgmt_2_r(void)
230{
231 return 0x0017e2b0;
232}
233static inline u32 ltc_ltcs_ltss_tstg_set_mgmt_2_l2_bypass_mode_enabled_f(void)
234{
235 return 0x10000000;
236}
237static inline u32 ltc_ltcs_ltss_g_elpg_r(void)
238{
239 return 0x0017e214;
240}
241static inline u32 ltc_ltcs_ltss_g_elpg_flush_v(u32 r)
242{
243 return (r >> 0) & 0x1;
244}
245static inline u32 ltc_ltcs_ltss_g_elpg_flush_pending_v(void)
246{
247 return 0x00000001;
248}
249static inline u32 ltc_ltcs_ltss_g_elpg_flush_pending_f(void)
250{
251 return 0x1;
252}
253static inline u32 ltc_ltc0_ltss_g_elpg_r(void)
254{
255 return 0x00140214;
256}
257static inline u32 ltc_ltc0_ltss_g_elpg_flush_v(u32 r)
258{
259 return (r >> 0) & 0x1;
260}
261static inline u32 ltc_ltc0_ltss_g_elpg_flush_pending_v(void)
262{
263 return 0x00000001;
264}
265static inline u32 ltc_ltc0_ltss_g_elpg_flush_pending_f(void)
266{
267 return 0x1;
268}
269static inline u32 ltc_ltc1_ltss_g_elpg_r(void)
270{
271 return 0x00142214;
272}
273static inline u32 ltc_ltc1_ltss_g_elpg_flush_v(u32 r)
274{
275 return (r >> 0) & 0x1;
276}
277static inline u32 ltc_ltc1_ltss_g_elpg_flush_pending_v(void)
278{
279 return 0x00000001;
280}
281static inline u32 ltc_ltc1_ltss_g_elpg_flush_pending_f(void)
282{
283 return 0x1;
284}
285static inline u32 ltc_ltcs_ltss_intr_r(void)
286{
287 return 0x0017e20c;
288}
289static inline u32 ltc_ltcs_ltss_intr_ecc_sec_error_pending_f(void)
290{
291 return 0x100;
292}
293static inline u32 ltc_ltcs_ltss_intr_ecc_ded_error_pending_f(void)
294{
295 return 0x200;
296}
297static inline u32 ltc_ltcs_ltss_intr_en_evicted_cb_m(void)
298{
299 return 0x1 << 20;
300}
301static inline u32 ltc_ltcs_ltss_intr_en_illegal_compstat_access_m(void)
302{
303 return 0x1 << 30;
304}
305static inline u32 ltc_ltcs_ltss_intr_en_ecc_sec_error_enabled_f(void)
306{
307 return 0x1000000;
308}
309static inline u32 ltc_ltcs_ltss_intr_en_ecc_ded_error_enabled_f(void)
310{
311 return 0x2000000;
312}
313static inline u32 ltc_ltc0_lts0_intr_r(void)
314{
315 return 0x0014040c;
316}
317static inline u32 ltc_ltc0_lts0_dstg_ecc_report_r(void)
318{
319 return 0x0014051c;
320}
321static inline u32 ltc_ltc0_lts0_dstg_ecc_report_sec_count_m(void)
322{
323 return 0xff << 0;
324}
325static inline u32 ltc_ltc0_lts0_dstg_ecc_report_sec_count_v(u32 r)
326{
327 return (r >> 0) & 0xff;
328}
329static inline u32 ltc_ltc0_lts0_dstg_ecc_report_ded_count_m(void)
330{
331 return 0xff << 16;
332}
333static inline u32 ltc_ltc0_lts0_dstg_ecc_report_ded_count_v(u32 r)
334{
335 return (r >> 16) & 0xff;
336}
337static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_r(void)
338{
339 return 0x0017e2a0;
340}
341static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_v(u32 r)
342{
343 return (r >> 0) & 0x1;
344}
345static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_pending_v(void)
346{
347 return 0x00000001;
348}
349static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_pending_f(void)
350{
351 return 0x1;
352}
353static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_max_cycles_between_invalidates_v(u32 r)
354{
355 return (r >> 8) & 0xf;
356}
357static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_max_cycles_between_invalidates_3_v(void)
358{
359 return 0x00000003;
360}
361static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_max_cycles_between_invalidates_3_f(void)
362{
363 return 0x300;
364}
365static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_last_class_v(u32 r)
366{
367 return (r >> 28) & 0x1;
368}
369static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_last_class_true_v(void)
370{
371 return 0x00000001;
372}
373static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_last_class_true_f(void)
374{
375 return 0x10000000;
376}
377static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_normal_class_v(u32 r)
378{
379 return (r >> 29) & 0x1;
380}
381static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_normal_class_true_v(void)
382{
383 return 0x00000001;
384}
385static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_normal_class_true_f(void)
386{
387 return 0x20000000;
388}
389static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_first_class_v(u32 r)
390{
391 return (r >> 30) & 0x1;
392}
393static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_first_class_true_v(void)
394{
395 return 0x00000001;
396}
397static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_first_class_true_f(void)
398{
399 return 0x40000000;
400}
401static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_r(void)
402{
403 return 0x0017e2a4;
404}
405static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_v(u32 r)
406{
407 return (r >> 0) & 0x1;
408}
409static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_pending_v(void)
410{
411 return 0x00000001;
412}
413static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_pending_f(void)
414{
415 return 0x1;
416}
417static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_max_cycles_between_cleans_v(u32 r)
418{
419 return (r >> 8) & 0xf;
420}
421static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_max_cycles_between_cleans_3_v(void)
422{
423 return 0x00000003;
424}
425static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_max_cycles_between_cleans_3_f(void)
426{
427 return 0x300;
428}
429static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_wait_for_fb_to_pull_v(u32 r)
430{
431 return (r >> 16) & 0x1;
432}
433static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_wait_for_fb_to_pull_true_v(void)
434{
435 return 0x00000001;
436}
437static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_wait_for_fb_to_pull_true_f(void)
438{
439 return 0x10000;
440}
441static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_last_class_v(u32 r)
442{
443 return (r >> 28) & 0x1;
444}
445static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_last_class_true_v(void)
446{
447 return 0x00000001;
448}
449static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_last_class_true_f(void)
450{
451 return 0x10000000;
452}
453static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_normal_class_v(u32 r)
454{
455 return (r >> 29) & 0x1;
456}
457static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_normal_class_true_v(void)
458{
459 return 0x00000001;
460}
461static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_normal_class_true_f(void)
462{
463 return 0x20000000;
464}
465static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_first_class_v(u32 r)
466{
467 return (r >> 30) & 0x1;
468}
469static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_first_class_true_v(void)
470{
471 return 0x00000001;
472}
473static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_first_class_true_f(void)
474{
475 return 0x40000000;
476}
477static inline u32 ltc_ltc0_ltss_tstg_cmgmt0_r(void)
478{
479 return 0x001402a0;
480}
481static inline u32 ltc_ltc0_ltss_tstg_cmgmt0_invalidate_v(u32 r)
482{
483 return (r >> 0) & 0x1;
484}
485static inline u32 ltc_ltc0_ltss_tstg_cmgmt0_invalidate_pending_v(void)
486{
487 return 0x00000001;
488}
489static inline u32 ltc_ltc0_ltss_tstg_cmgmt0_invalidate_pending_f(void)
490{
491 return 0x1;
492}
493static inline u32 ltc_ltc0_ltss_tstg_cmgmt1_r(void)
494{
495 return 0x001402a4;
496}
497static inline u32 ltc_ltc0_ltss_tstg_cmgmt1_clean_v(u32 r)
498{
499 return (r >> 0) & 0x1;
500}
501static inline u32 ltc_ltc0_ltss_tstg_cmgmt1_clean_pending_v(void)
502{
503 return 0x00000001;
504}
505static inline u32 ltc_ltc0_ltss_tstg_cmgmt1_clean_pending_f(void)
506{
507 return 0x1;
508}
509static inline u32 ltc_ltc1_ltss_tstg_cmgmt0_r(void)
510{
511 return 0x001422a0;
512}
513static inline u32 ltc_ltc1_ltss_tstg_cmgmt0_invalidate_v(u32 r)
514{
515 return (r >> 0) & 0x1;
516}
517static inline u32 ltc_ltc1_ltss_tstg_cmgmt0_invalidate_pending_v(void)
518{
519 return 0x00000001;
520}
521static inline u32 ltc_ltc1_ltss_tstg_cmgmt0_invalidate_pending_f(void)
522{
523 return 0x1;
524}
525static inline u32 ltc_ltc1_ltss_tstg_cmgmt1_r(void)
526{
527 return 0x001422a4;
528}
529static inline u32 ltc_ltc1_ltss_tstg_cmgmt1_clean_v(u32 r)
530{
531 return (r >> 0) & 0x1;
532}
533static inline u32 ltc_ltc1_ltss_tstg_cmgmt1_clean_pending_v(void)
534{
535 return 0x00000001;
536}
537static inline u32 ltc_ltc1_ltss_tstg_cmgmt1_clean_pending_f(void)
538{
539 return 0x1;
540}
541static inline u32 ltc_ltc0_lts0_tstg_info_1_r(void)
542{
543 return 0x0014058c;
544}
545static inline u32 ltc_ltc0_lts0_tstg_info_1_slice_size_in_kb_v(u32 r)
546{
547 return (r >> 0) & 0xffff;
548}
549static inline u32 ltc_ltc0_lts0_tstg_info_1_slices_per_l2_v(u32 r)
550{
551 return (r >> 16) & 0x1f;
552}
553#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_mc_gp106.h b/drivers/gpu/nvgpu/gp106/hw_mc_gp106.h
new file mode 100644
index 00000000..99ad8bc0
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_mc_gp106.h
@@ -0,0 +1,245 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_mc_gp106_h_
51#define _hw_mc_gp106_h_
52
53static inline u32 mc_boot_0_r(void)
54{
55 return 0x00000000;
56}
57static inline u32 mc_boot_0_architecture_v(u32 r)
58{
59 return (r >> 24) & 0x1f;
60}
61static inline u32 mc_boot_0_implementation_v(u32 r)
62{
63 return (r >> 20) & 0xf;
64}
65static inline u32 mc_boot_0_major_revision_v(u32 r)
66{
67 return (r >> 4) & 0xf;
68}
69static inline u32 mc_boot_0_minor_revision_v(u32 r)
70{
71 return (r >> 0) & 0xf;
72}
73static inline u32 mc_intr_r(u32 i)
74{
75 return 0x00000100 + i*4;
76}
77static inline u32 mc_intr_pfifo_pending_f(void)
78{
79 return 0x100;
80}
81static inline u32 mc_intr_replayable_fault_pending_f(void)
82{
83 return 0x200;
84}
85static inline u32 mc_intr_pgraph_pending_f(void)
86{
87 return 0x1000;
88}
89static inline u32 mc_intr_pmu_pending_f(void)
90{
91 return 0x1000000;
92}
93static inline u32 mc_intr_ltc_pending_f(void)
94{
95 return 0x2000000;
96}
97static inline u32 mc_intr_priv_ring_pending_f(void)
98{
99 return 0x40000000;
100}
101static inline u32 mc_intr_pbus_pending_f(void)
102{
103 return 0x10000000;
104}
105static inline u32 mc_intr_en_r(u32 i)
106{
107 return 0x00000140 + i*4;
108}
109static inline u32 mc_intr_en_set_r(u32 i)
110{
111 return 0x00000160 + i*4;
112}
113static inline u32 mc_intr_en_clear_r(u32 i)
114{
115 return 0x00000180 + i*4;
116}
117static inline u32 mc_enable_r(void)
118{
119 return 0x00000200;
120}
121static inline u32 mc_enable_xbar_enabled_f(void)
122{
123 return 0x4;
124}
125static inline u32 mc_enable_l2_enabled_f(void)
126{
127 return 0x8;
128}
129static inline u32 mc_enable_pmedia_s(void)
130{
131 return 1;
132}
133static inline u32 mc_enable_pmedia_f(u32 v)
134{
135 return (v & 0x1) << 4;
136}
137static inline u32 mc_enable_pmedia_m(void)
138{
139 return 0x1 << 4;
140}
141static inline u32 mc_enable_pmedia_v(u32 r)
142{
143 return (r >> 4) & 0x1;
144}
145static inline u32 mc_enable_priv_ring_enabled_f(void)
146{
147 return 0x20;
148}
149static inline u32 mc_enable_ce0_m(void)
150{
151 return 0x1 << 6;
152}
153static inline u32 mc_enable_pfifo_enabled_f(void)
154{
155 return 0x100;
156}
157static inline u32 mc_enable_pgraph_enabled_f(void)
158{
159 return 0x1000;
160}
161static inline u32 mc_enable_pwr_v(u32 r)
162{
163 return (r >> 13) & 0x1;
164}
165static inline u32 mc_enable_pwr_disabled_v(void)
166{
167 return 0x00000000;
168}
169static inline u32 mc_enable_pwr_enabled_f(void)
170{
171 return 0x2000;
172}
173static inline u32 mc_enable_pfb_enabled_f(void)
174{
175 return 0x100000;
176}
177static inline u32 mc_enable_ce2_m(void)
178{
179 return 0x1 << 21;
180}
181static inline u32 mc_enable_ce2_enabled_f(void)
182{
183 return 0x200000;
184}
185static inline u32 mc_enable_blg_enabled_f(void)
186{
187 return 0x8000000;
188}
189static inline u32 mc_enable_perfmon_enabled_f(void)
190{
191 return 0x10000000;
192}
193static inline u32 mc_enable_hub_enabled_f(void)
194{
195 return 0x20000000;
196}
197static inline u32 mc_intr_ltc_r(void)
198{
199 return 0x000001c0;
200}
201static inline u32 mc_enable_pb_r(void)
202{
203 return 0x00000204;
204}
205static inline u32 mc_enable_pb_0_s(void)
206{
207 return 1;
208}
209static inline u32 mc_enable_pb_0_f(u32 v)
210{
211 return (v & 0x1) << 0;
212}
213static inline u32 mc_enable_pb_0_m(void)
214{
215 return 0x1 << 0;
216}
217static inline u32 mc_enable_pb_0_v(u32 r)
218{
219 return (r >> 0) & 0x1;
220}
221static inline u32 mc_enable_pb_0_enabled_v(void)
222{
223 return 0x00000001;
224}
225static inline u32 mc_enable_pb_sel_f(u32 v, u32 i)
226{
227 return (v & 0x1) << (0 + i*1);
228}
229static inline u32 mc_elpg_enable_r(void)
230{
231 return 0x0000020c;
232}
233static inline u32 mc_elpg_enable_xbar_enabled_f(void)
234{
235 return 0x4;
236}
237static inline u32 mc_elpg_enable_pfb_enabled_f(void)
238{
239 return 0x100000;
240}
241static inline u32 mc_elpg_enable_hub_enabled_f(void)
242{
243 return 0x20000000;
244}
245#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_pbdma_gp106.h b/drivers/gpu/nvgpu/gp106/hw_pbdma_gp106.h
new file mode 100644
index 00000000..1e299bae
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_pbdma_gp106.h
@@ -0,0 +1,513 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_pbdma_gp106_h_
51#define _hw_pbdma_gp106_h_
52
53static inline u32 pbdma_gp_entry1_r(void)
54{
55 return 0x10000004;
56}
57static inline u32 pbdma_gp_entry1_get_hi_v(u32 r)
58{
59 return (r >> 0) & 0xff;
60}
61static inline u32 pbdma_gp_entry1_length_f(u32 v)
62{
63 return (v & 0x1fffff) << 10;
64}
65static inline u32 pbdma_gp_entry1_length_v(u32 r)
66{
67 return (r >> 10) & 0x1fffff;
68}
69static inline u32 pbdma_gp_base_r(u32 i)
70{
71 return 0x00040048 + i*8192;
72}
73static inline u32 pbdma_gp_base__size_1_v(void)
74{
75 return 0x00000004;
76}
77static inline u32 pbdma_gp_base_offset_f(u32 v)
78{
79 return (v & 0x1fffffff) << 3;
80}
81static inline u32 pbdma_gp_base_rsvd_s(void)
82{
83 return 3;
84}
85static inline u32 pbdma_gp_base_hi_r(u32 i)
86{
87 return 0x0004004c + i*8192;
88}
89static inline u32 pbdma_gp_base_hi_offset_f(u32 v)
90{
91 return (v & 0xff) << 0;
92}
93static inline u32 pbdma_gp_base_hi_limit2_f(u32 v)
94{
95 return (v & 0x1f) << 16;
96}
97static inline u32 pbdma_gp_fetch_r(u32 i)
98{
99 return 0x00040050 + i*8192;
100}
101static inline u32 pbdma_gp_get_r(u32 i)
102{
103 return 0x00040014 + i*8192;
104}
105static inline u32 pbdma_gp_put_r(u32 i)
106{
107 return 0x00040000 + i*8192;
108}
109static inline u32 pbdma_pb_fetch_r(u32 i)
110{
111 return 0x00040054 + i*8192;
112}
113static inline u32 pbdma_pb_fetch_hi_r(u32 i)
114{
115 return 0x00040058 + i*8192;
116}
117static inline u32 pbdma_get_r(u32 i)
118{
119 return 0x00040018 + i*8192;
120}
121static inline u32 pbdma_get_hi_r(u32 i)
122{
123 return 0x0004001c + i*8192;
124}
125static inline u32 pbdma_put_r(u32 i)
126{
127 return 0x0004005c + i*8192;
128}
129static inline u32 pbdma_put_hi_r(u32 i)
130{
131 return 0x00040060 + i*8192;
132}
133static inline u32 pbdma_formats_r(u32 i)
134{
135 return 0x0004009c + i*8192;
136}
137static inline u32 pbdma_formats_gp_fermi0_f(void)
138{
139 return 0x0;
140}
141static inline u32 pbdma_formats_pb_fermi1_f(void)
142{
143 return 0x100;
144}
145static inline u32 pbdma_formats_mp_fermi0_f(void)
146{
147 return 0x0;
148}
149static inline u32 pbdma_pb_header_r(u32 i)
150{
151 return 0x00040084 + i*8192;
152}
153static inline u32 pbdma_pb_header_priv_user_f(void)
154{
155 return 0x0;
156}
157static inline u32 pbdma_pb_header_method_zero_f(void)
158{
159 return 0x0;
160}
161static inline u32 pbdma_pb_header_subchannel_zero_f(void)
162{
163 return 0x0;
164}
165static inline u32 pbdma_pb_header_level_main_f(void)
166{
167 return 0x0;
168}
169static inline u32 pbdma_pb_header_first_true_f(void)
170{
171 return 0x400000;
172}
173static inline u32 pbdma_pb_header_type_inc_f(void)
174{
175 return 0x20000000;
176}
177static inline u32 pbdma_pb_header_type_non_inc_f(void)
178{
179 return 0x60000000;
180}
181static inline u32 pbdma_hdr_shadow_r(u32 i)
182{
183 return 0x00040118 + i*8192;
184}
185static inline u32 pbdma_subdevice_r(u32 i)
186{
187 return 0x00040094 + i*8192;
188}
189static inline u32 pbdma_subdevice_id_f(u32 v)
190{
191 return (v & 0xfff) << 0;
192}
193static inline u32 pbdma_subdevice_status_active_f(void)
194{
195 return 0x10000000;
196}
197static inline u32 pbdma_subdevice_channel_dma_enable_f(void)
198{
199 return 0x20000000;
200}
201static inline u32 pbdma_method0_r(u32 i)
202{
203 return 0x000400c0 + i*8192;
204}
205static inline u32 pbdma_method0_fifo_size_v(void)
206{
207 return 0x00000004;
208}
209static inline u32 pbdma_method0_addr_f(u32 v)
210{
211 return (v & 0xfff) << 2;
212}
213static inline u32 pbdma_method0_addr_v(u32 r)
214{
215 return (r >> 2) & 0xfff;
216}
217static inline u32 pbdma_method0_subch_v(u32 r)
218{
219 return (r >> 16) & 0x7;
220}
221static inline u32 pbdma_method0_first_true_f(void)
222{
223 return 0x400000;
224}
225static inline u32 pbdma_method0_valid_true_f(void)
226{
227 return 0x80000000;
228}
229static inline u32 pbdma_method1_r(u32 i)
230{
231 return 0x000400c8 + i*8192;
232}
233static inline u32 pbdma_method2_r(u32 i)
234{
235 return 0x000400d0 + i*8192;
236}
237static inline u32 pbdma_method3_r(u32 i)
238{
239 return 0x000400d8 + i*8192;
240}
241static inline u32 pbdma_data0_r(u32 i)
242{
243 return 0x000400c4 + i*8192;
244}
245static inline u32 pbdma_target_r(u32 i)
246{
247 return 0x000400ac + i*8192;
248}
249static inline u32 pbdma_target_engine_sw_f(void)
250{
251 return 0x1f;
252}
253static inline u32 pbdma_acquire_r(u32 i)
254{
255 return 0x00040030 + i*8192;
256}
257static inline u32 pbdma_acquire_retry_man_2_f(void)
258{
259 return 0x2;
260}
261static inline u32 pbdma_acquire_retry_exp_2_f(void)
262{
263 return 0x100;
264}
265static inline u32 pbdma_acquire_timeout_exp_max_f(void)
266{
267 return 0x7800;
268}
269static inline u32 pbdma_acquire_timeout_man_max_f(void)
270{
271 return 0x7fff8000;
272}
273static inline u32 pbdma_acquire_timeout_en_disable_f(void)
274{
275 return 0x0;
276}
277static inline u32 pbdma_status_r(u32 i)
278{
279 return 0x00040100 + i*8192;
280}
281static inline u32 pbdma_channel_r(u32 i)
282{
283 return 0x00040120 + i*8192;
284}
285static inline u32 pbdma_signature_r(u32 i)
286{
287 return 0x00040010 + i*8192;
288}
289static inline u32 pbdma_signature_hw_valid_f(void)
290{
291 return 0xface;
292}
293static inline u32 pbdma_signature_sw_zero_f(void)
294{
295 return 0x0;
296}
297static inline u32 pbdma_userd_r(u32 i)
298{
299 return 0x00040008 + i*8192;
300}
301static inline u32 pbdma_userd_target_vid_mem_f(void)
302{
303 return 0x0;
304}
305static inline u32 pbdma_userd_target_sys_mem_coh_f(void)
306{
307 return 0x2;
308}
309static inline u32 pbdma_userd_target_sys_mem_ncoh_f(void)
310{
311 return 0x3;
312}
313static inline u32 pbdma_userd_addr_f(u32 v)
314{
315 return (v & 0x7fffff) << 9;
316}
317static inline u32 pbdma_userd_hi_r(u32 i)
318{
319 return 0x0004000c + i*8192;
320}
321static inline u32 pbdma_userd_hi_addr_f(u32 v)
322{
323 return (v & 0xff) << 0;
324}
325static inline u32 pbdma_config_r(u32 i)
326{
327 return 0x000400f4 + i*8192;
328}
329static inline u32 pbdma_config_auth_level_privileged_f(void)
330{
331 return 0x100;
332}
333static inline u32 pbdma_hce_ctrl_r(u32 i)
334{
335 return 0x000400e4 + i*8192;
336}
337static inline u32 pbdma_hce_ctrl_hce_priv_mode_yes_f(void)
338{
339 return 0x20;
340}
341static inline u32 pbdma_intr_0_r(u32 i)
342{
343 return 0x00040108 + i*8192;
344}
345static inline u32 pbdma_intr_0_memreq_v(u32 r)
346{
347 return (r >> 0) & 0x1;
348}
349static inline u32 pbdma_intr_0_memreq_pending_f(void)
350{
351 return 0x1;
352}
353static inline u32 pbdma_intr_0_memack_timeout_pending_f(void)
354{
355 return 0x2;
356}
357static inline u32 pbdma_intr_0_memack_extra_pending_f(void)
358{
359 return 0x4;
360}
361static inline u32 pbdma_intr_0_memdat_timeout_pending_f(void)
362{
363 return 0x8;
364}
365static inline u32 pbdma_intr_0_memdat_extra_pending_f(void)
366{
367 return 0x10;
368}
369static inline u32 pbdma_intr_0_memflush_pending_f(void)
370{
371 return 0x20;
372}
373static inline u32 pbdma_intr_0_memop_pending_f(void)
374{
375 return 0x40;
376}
377static inline u32 pbdma_intr_0_lbconnect_pending_f(void)
378{
379 return 0x80;
380}
381static inline u32 pbdma_intr_0_lbreq_pending_f(void)
382{
383 return 0x100;
384}
385static inline u32 pbdma_intr_0_lback_timeout_pending_f(void)
386{
387 return 0x200;
388}
389static inline u32 pbdma_intr_0_lback_extra_pending_f(void)
390{
391 return 0x400;
392}
393static inline u32 pbdma_intr_0_lbdat_timeout_pending_f(void)
394{
395 return 0x800;
396}
397static inline u32 pbdma_intr_0_lbdat_extra_pending_f(void)
398{
399 return 0x1000;
400}
401static inline u32 pbdma_intr_0_gpfifo_pending_f(void)
402{
403 return 0x2000;
404}
405static inline u32 pbdma_intr_0_gpptr_pending_f(void)
406{
407 return 0x4000;
408}
409static inline u32 pbdma_intr_0_gpentry_pending_f(void)
410{
411 return 0x8000;
412}
413static inline u32 pbdma_intr_0_gpcrc_pending_f(void)
414{
415 return 0x10000;
416}
417static inline u32 pbdma_intr_0_pbptr_pending_f(void)
418{
419 return 0x20000;
420}
421static inline u32 pbdma_intr_0_pbentry_pending_f(void)
422{
423 return 0x40000;
424}
425static inline u32 pbdma_intr_0_pbcrc_pending_f(void)
426{
427 return 0x80000;
428}
429static inline u32 pbdma_intr_0_xbarconnect_pending_f(void)
430{
431 return 0x100000;
432}
433static inline u32 pbdma_intr_0_method_pending_f(void)
434{
435 return 0x200000;
436}
437static inline u32 pbdma_intr_0_methodcrc_pending_f(void)
438{
439 return 0x400000;
440}
441static inline u32 pbdma_intr_0_device_pending_f(void)
442{
443 return 0x800000;
444}
445static inline u32 pbdma_intr_0_semaphore_pending_f(void)
446{
447 return 0x2000000;
448}
449static inline u32 pbdma_intr_0_acquire_pending_f(void)
450{
451 return 0x4000000;
452}
453static inline u32 pbdma_intr_0_pri_pending_f(void)
454{
455 return 0x8000000;
456}
457static inline u32 pbdma_intr_0_no_ctxsw_seg_pending_f(void)
458{
459 return 0x20000000;
460}
461static inline u32 pbdma_intr_0_pbseg_pending_f(void)
462{
463 return 0x40000000;
464}
465static inline u32 pbdma_intr_0_signature_pending_f(void)
466{
467 return 0x80000000;
468}
469static inline u32 pbdma_intr_1_r(u32 i)
470{
471 return 0x00040148 + i*8192;
472}
473static inline u32 pbdma_intr_en_0_r(u32 i)
474{
475 return 0x0004010c + i*8192;
476}
477static inline u32 pbdma_intr_en_0_lbreq_enabled_f(void)
478{
479 return 0x100;
480}
481static inline u32 pbdma_intr_en_1_r(u32 i)
482{
483 return 0x0004014c + i*8192;
484}
485static inline u32 pbdma_intr_stall_r(u32 i)
486{
487 return 0x0004013c + i*8192;
488}
489static inline u32 pbdma_intr_stall_lbreq_enabled_f(void)
490{
491 return 0x100;
492}
493static inline u32 pbdma_udma_nop_r(void)
494{
495 return 0x00000008;
496}
497static inline u32 pbdma_runlist_timeslice_r(u32 i)
498{
499 return 0x000400f8 + i*8192;
500}
501static inline u32 pbdma_runlist_timeslice_timeout_128_f(void)
502{
503 return 0x80;
504}
505static inline u32 pbdma_runlist_timeslice_timescale_3_f(void)
506{
507 return 0x3000;
508}
509static inline u32 pbdma_runlist_timeslice_enable_true_f(void)
510{
511 return 0x10000000;
512}
513#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_perf_gp106.h b/drivers/gpu/nvgpu/gp106/hw_perf_gp106.h
new file mode 100644
index 00000000..cd3501a8
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_perf_gp106.h
@@ -0,0 +1,205 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_perf_gp106_h_
51#define _hw_perf_gp106_h_
52
53static inline u32 perf_pmasys_control_r(void)
54{
55 return 0x001b4000;
56}
57static inline u32 perf_pmasys_control_membuf_status_v(u32 r)
58{
59 return (r >> 4) & 0x1;
60}
61static inline u32 perf_pmasys_control_membuf_status_overflowed_v(void)
62{
63 return 0x00000001;
64}
65static inline u32 perf_pmasys_control_membuf_status_overflowed_f(void)
66{
67 return 0x10;
68}
69static inline u32 perf_pmasys_control_membuf_clear_status_f(u32 v)
70{
71 return (v & 0x1) << 5;
72}
73static inline u32 perf_pmasys_control_membuf_clear_status_v(u32 r)
74{
75 return (r >> 5) & 0x1;
76}
77static inline u32 perf_pmasys_control_membuf_clear_status_doit_v(void)
78{
79 return 0x00000001;
80}
81static inline u32 perf_pmasys_control_membuf_clear_status_doit_f(void)
82{
83 return 0x20;
84}
85static inline u32 perf_pmasys_mem_block_r(void)
86{
87 return 0x001b4070;
88}
89static inline u32 perf_pmasys_mem_block_base_f(u32 v)
90{
91 return (v & 0xfffffff) << 0;
92}
93static inline u32 perf_pmasys_mem_block_target_f(u32 v)
94{
95 return (v & 0x3) << 28;
96}
97static inline u32 perf_pmasys_mem_block_target_v(u32 r)
98{
99 return (r >> 28) & 0x3;
100}
101static inline u32 perf_pmasys_mem_block_target_lfb_v(void)
102{
103 return 0x00000000;
104}
105static inline u32 perf_pmasys_mem_block_target_lfb_f(void)
106{
107 return 0x0;
108}
109static inline u32 perf_pmasys_mem_block_target_sys_coh_v(void)
110{
111 return 0x00000002;
112}
113static inline u32 perf_pmasys_mem_block_target_sys_coh_f(void)
114{
115 return 0x20000000;
116}
117static inline u32 perf_pmasys_mem_block_target_sys_ncoh_v(void)
118{
119 return 0x00000003;
120}
121static inline u32 perf_pmasys_mem_block_target_sys_ncoh_f(void)
122{
123 return 0x30000000;
124}
125static inline u32 perf_pmasys_mem_block_valid_f(u32 v)
126{
127 return (v & 0x1) << 31;
128}
129static inline u32 perf_pmasys_mem_block_valid_v(u32 r)
130{
131 return (r >> 31) & 0x1;
132}
133static inline u32 perf_pmasys_mem_block_valid_true_v(void)
134{
135 return 0x00000001;
136}
137static inline u32 perf_pmasys_mem_block_valid_true_f(void)
138{
139 return 0x80000000;
140}
141static inline u32 perf_pmasys_mem_block_valid_false_v(void)
142{
143 return 0x00000000;
144}
145static inline u32 perf_pmasys_mem_block_valid_false_f(void)
146{
147 return 0x0;
148}
149static inline u32 perf_pmasys_outbase_r(void)
150{
151 return 0x001b4074;
152}
153static inline u32 perf_pmasys_outbase_ptr_f(u32 v)
154{
155 return (v & 0x7ffffff) << 5;
156}
157static inline u32 perf_pmasys_outbaseupper_r(void)
158{
159 return 0x001b4078;
160}
161static inline u32 perf_pmasys_outbaseupper_ptr_f(u32 v)
162{
163 return (v & 0xff) << 0;
164}
165static inline u32 perf_pmasys_outsize_r(void)
166{
167 return 0x001b407c;
168}
169static inline u32 perf_pmasys_outsize_numbytes_f(u32 v)
170{
171 return (v & 0x7ffffff) << 5;
172}
173static inline u32 perf_pmasys_mem_bytes_r(void)
174{
175 return 0x001b4084;
176}
177static inline u32 perf_pmasys_mem_bytes_numbytes_f(u32 v)
178{
179 return (v & 0xfffffff) << 4;
180}
181static inline u32 perf_pmasys_mem_bump_r(void)
182{
183 return 0x001b4088;
184}
185static inline u32 perf_pmasys_mem_bump_numbytes_f(u32 v)
186{
187 return (v & 0xfffffff) << 4;
188}
189static inline u32 perf_pmasys_enginestatus_r(void)
190{
191 return 0x001b40a4;
192}
193static inline u32 perf_pmasys_enginestatus_rbufempty_f(u32 v)
194{
195 return (v & 0x1) << 4;
196}
197static inline u32 perf_pmasys_enginestatus_rbufempty_empty_v(void)
198{
199 return 0x00000001;
200}
201static inline u32 perf_pmasys_enginestatus_rbufempty_empty_f(void)
202{
203 return 0x10;
204}
205#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_pri_ringmaster_gp106.h b/drivers/gpu/nvgpu/gp106/hw_pri_ringmaster_gp106.h
new file mode 100644
index 00000000..0eb2187a
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_pri_ringmaster_gp106.h
@@ -0,0 +1,145 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_pri_ringmaster_gp106_h_
51#define _hw_pri_ringmaster_gp106_h_
52
53static inline u32 pri_ringmaster_command_r(void)
54{
55 return 0x0012004c;
56}
57static inline u32 pri_ringmaster_command_cmd_m(void)
58{
59 return 0x3f << 0;
60}
61static inline u32 pri_ringmaster_command_cmd_v(u32 r)
62{
63 return (r >> 0) & 0x3f;
64}
65static inline u32 pri_ringmaster_command_cmd_no_cmd_v(void)
66{
67 return 0x00000000;
68}
69static inline u32 pri_ringmaster_command_cmd_start_ring_f(void)
70{
71 return 0x1;
72}
73static inline u32 pri_ringmaster_command_cmd_ack_interrupt_f(void)
74{
75 return 0x2;
76}
77static inline u32 pri_ringmaster_command_cmd_enumerate_stations_f(void)
78{
79 return 0x3;
80}
81static inline u32 pri_ringmaster_command_cmd_enumerate_stations_bc_grp_all_f(void)
82{
83 return 0x0;
84}
85static inline u32 pri_ringmaster_command_data_r(void)
86{
87 return 0x00120048;
88}
89static inline u32 pri_ringmaster_start_results_r(void)
90{
91 return 0x00120050;
92}
93static inline u32 pri_ringmaster_start_results_connectivity_v(u32 r)
94{
95 return (r >> 0) & 0x1;
96}
97static inline u32 pri_ringmaster_start_results_connectivity_pass_v(void)
98{
99 return 0x00000001;
100}
101static inline u32 pri_ringmaster_intr_status0_r(void)
102{
103 return 0x00120058;
104}
105static inline u32 pri_ringmaster_intr_status1_r(void)
106{
107 return 0x0012005c;
108}
109static inline u32 pri_ringmaster_global_ctl_r(void)
110{
111 return 0x00120060;
112}
113static inline u32 pri_ringmaster_global_ctl_ring_reset_asserted_f(void)
114{
115 return 0x1;
116}
117static inline u32 pri_ringmaster_global_ctl_ring_reset_deasserted_f(void)
118{
119 return 0x0;
120}
121static inline u32 pri_ringmaster_enum_fbp_r(void)
122{
123 return 0x00120074;
124}
125static inline u32 pri_ringmaster_enum_fbp_count_v(u32 r)
126{
127 return (r >> 0) & 0x1f;
128}
129static inline u32 pri_ringmaster_enum_gpc_r(void)
130{
131 return 0x00120078;
132}
133static inline u32 pri_ringmaster_enum_gpc_count_v(u32 r)
134{
135 return (r >> 0) & 0x1f;
136}
137static inline u32 pri_ringmaster_enum_ltc_r(void)
138{
139 return 0x0012006c;
140}
141static inline u32 pri_ringmaster_enum_ltc_count_v(u32 r)
142{
143 return (r >> 0) & 0x1f;
144}
145#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_pri_ringstation_sys_gp106.h b/drivers/gpu/nvgpu/gp106/hw_pri_ringstation_sys_gp106.h
new file mode 100644
index 00000000..a22d6a05
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_pri_ringstation_sys_gp106.h
@@ -0,0 +1,69 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_pri_ringstation_sys_gp106_h_
51#define _hw_pri_ringstation_sys_gp106_h_
52
53static inline u32 pri_ringstation_sys_master_config_r(u32 i)
54{
55 return 0x00122300 + i*4;
56}
57static inline u32 pri_ringstation_sys_decode_config_r(void)
58{
59 return 0x00122204;
60}
61static inline u32 pri_ringstation_sys_decode_config_ring_m(void)
62{
63 return 0x7 << 0;
64}
65static inline u32 pri_ringstation_sys_decode_config_ring_drop_on_ring_not_started_f(void)
66{
67 return 0x1;
68}
69#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_proj_gp106.h b/drivers/gpu/nvgpu/gp106/hw_proj_gp106.h
new file mode 100644
index 00000000..8042bcae
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_proj_gp106.h
@@ -0,0 +1,165 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_proj_gp106_h_
51#define _hw_proj_gp106_h_
52
53static inline u32 proj_gpc_base_v(void)
54{
55 return 0x00500000;
56}
57static inline u32 proj_gpc_shared_base_v(void)
58{
59 return 0x00418000;
60}
61static inline u32 proj_gpc_stride_v(void)
62{
63 return 0x00008000;
64}
65static inline u32 proj_ltc_stride_v(void)
66{
67 return 0x00002000;
68}
69static inline u32 proj_lts_stride_v(void)
70{
71 return 0x00000200;
72}
73static inline u32 proj_fbpa_base_v(void)
74{
75 return 0x00900000;
76}
77static inline u32 proj_fbpa_shared_base_v(void)
78{
79 return 0x009a0000;
80}
81static inline u32 proj_fbpa_stride_v(void)
82{
83 return 0x00004000;
84}
85static inline u32 proj_ppc_in_gpc_base_v(void)
86{
87 return 0x00003000;
88}
89static inline u32 proj_ppc_in_gpc_shared_base_v(void)
90{
91 return 0x00003e00;
92}
93static inline u32 proj_ppc_in_gpc_stride_v(void)
94{
95 return 0x00000200;
96}
97static inline u32 proj_rop_base_v(void)
98{
99 return 0x00410000;
100}
101static inline u32 proj_rop_shared_base_v(void)
102{
103 return 0x00408800;
104}
105static inline u32 proj_rop_stride_v(void)
106{
107 return 0x00000400;
108}
109static inline u32 proj_tpc_in_gpc_base_v(void)
110{
111 return 0x00004000;
112}
113static inline u32 proj_tpc_in_gpc_stride_v(void)
114{
115 return 0x00000800;
116}
117static inline u32 proj_tpc_in_gpc_shared_base_v(void)
118{
119 return 0x00001800;
120}
121static inline u32 proj_host_num_engines_v(void)
122{
123 return 0x00000009;
124}
125static inline u32 proj_host_num_pbdma_v(void)
126{
127 return 0x00000004;
128}
129static inline u32 proj_scal_litter_num_tpc_per_gpc_v(void)
130{
131 return 0x00000005;
132}
133static inline u32 proj_scal_litter_num_fbps_v(void)
134{
135 return 0x00000006;
136}
137static inline u32 proj_scal_litter_num_fbpas_v(void)
138{
139 return 0x00000006;
140}
141static inline u32 proj_scal_litter_num_gpcs_v(void)
142{
143 return 0x00000006;
144}
145static inline u32 proj_scal_litter_num_pes_per_gpc_v(void)
146{
147 return 0x00000003;
148}
149static inline u32 proj_scal_litter_num_tpcs_per_pes_v(void)
150{
151 return 0x00000002;
152}
153static inline u32 proj_scal_litter_num_zcull_banks_v(void)
154{
155 return 0x00000004;
156}
157static inline u32 proj_scal_max_gpcs_v(void)
158{
159 return 0x00000020;
160}
161static inline u32 proj_scal_max_tpc_per_gpc_v(void)
162{
163 return 0x00000008;
164}
165#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_psec_gp106.h b/drivers/gpu/nvgpu/gp106/hw_psec_gp106.h
new file mode 100644
index 00000000..f9c9f69c
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_psec_gp106.h
@@ -0,0 +1,609 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_psec_gp106_h_
51#define _hw_psec_gp106_h_
52
53static inline u32 psec_falcon_irqsset_r(void)
54{
55 return 0x00087000;
56}
57static inline u32 psec_falcon_irqsset_swgen0_set_f(void)
58{
59 return 0x40;
60}
61static inline u32 psec_falcon_irqsclr_r(void)
62{
63 return 0x00087004;
64}
65static inline u32 psec_falcon_irqstat_r(void)
66{
67 return 0x00087008;
68}
69static inline u32 psec_falcon_irqstat_halt_true_f(void)
70{
71 return 0x10;
72}
73static inline u32 psec_falcon_irqstat_exterr_true_f(void)
74{
75 return 0x20;
76}
77static inline u32 psec_falcon_irqstat_swgen0_true_f(void)
78{
79 return 0x40;
80}
81static inline u32 psec_falcon_irqmode_r(void)
82{
83 return 0x0008700c;
84}
85static inline u32 psec_falcon_irqmset_r(void)
86{
87 return 0x00087010;
88}
89static inline u32 psec_falcon_irqmset_gptmr_f(u32 v)
90{
91 return (v & 0x1) << 0;
92}
93static inline u32 psec_falcon_irqmset_wdtmr_f(u32 v)
94{
95 return (v & 0x1) << 1;
96}
97static inline u32 psec_falcon_irqmset_mthd_f(u32 v)
98{
99 return (v & 0x1) << 2;
100}
101static inline u32 psec_falcon_irqmset_ctxsw_f(u32 v)
102{
103 return (v & 0x1) << 3;
104}
105static inline u32 psec_falcon_irqmset_halt_f(u32 v)
106{
107 return (v & 0x1) << 4;
108}
109static inline u32 psec_falcon_irqmset_exterr_f(u32 v)
110{
111 return (v & 0x1) << 5;
112}
113static inline u32 psec_falcon_irqmset_swgen0_f(u32 v)
114{
115 return (v & 0x1) << 6;
116}
117static inline u32 psec_falcon_irqmset_swgen1_f(u32 v)
118{
119 return (v & 0x1) << 7;
120}
121static inline u32 psec_falcon_irqmclr_r(void)
122{
123 return 0x00087014;
124}
125static inline u32 psec_falcon_irqmclr_gptmr_f(u32 v)
126{
127 return (v & 0x1) << 0;
128}
129static inline u32 psec_falcon_irqmclr_wdtmr_f(u32 v)
130{
131 return (v & 0x1) << 1;
132}
133static inline u32 psec_falcon_irqmclr_mthd_f(u32 v)
134{
135 return (v & 0x1) << 2;
136}
137static inline u32 psec_falcon_irqmclr_ctxsw_f(u32 v)
138{
139 return (v & 0x1) << 3;
140}
141static inline u32 psec_falcon_irqmclr_halt_f(u32 v)
142{
143 return (v & 0x1) << 4;
144}
145static inline u32 psec_falcon_irqmclr_exterr_f(u32 v)
146{
147 return (v & 0x1) << 5;
148}
149static inline u32 psec_falcon_irqmclr_swgen0_f(u32 v)
150{
151 return (v & 0x1) << 6;
152}
153static inline u32 psec_falcon_irqmclr_swgen1_f(u32 v)
154{
155 return (v & 0x1) << 7;
156}
157static inline u32 psec_falcon_irqmclr_ext_f(u32 v)
158{
159 return (v & 0xff) << 8;
160}
161static inline u32 psec_falcon_irqmask_r(void)
162{
163 return 0x00087018;
164}
165static inline u32 psec_falcon_irqdest_r(void)
166{
167 return 0x0008701c;
168}
169static inline u32 psec_falcon_irqdest_host_gptmr_f(u32 v)
170{
171 return (v & 0x1) << 0;
172}
173static inline u32 psec_falcon_irqdest_host_wdtmr_f(u32 v)
174{
175 return (v & 0x1) << 1;
176}
177static inline u32 psec_falcon_irqdest_host_mthd_f(u32 v)
178{
179 return (v & 0x1) << 2;
180}
181static inline u32 psec_falcon_irqdest_host_ctxsw_f(u32 v)
182{
183 return (v & 0x1) << 3;
184}
185static inline u32 psec_falcon_irqdest_host_halt_f(u32 v)
186{
187 return (v & 0x1) << 4;
188}
189static inline u32 psec_falcon_irqdest_host_exterr_f(u32 v)
190{
191 return (v & 0x1) << 5;
192}
193static inline u32 psec_falcon_irqdest_host_swgen0_f(u32 v)
194{
195 return (v & 0x1) << 6;
196}
197static inline u32 psec_falcon_irqdest_host_swgen1_f(u32 v)
198{
199 return (v & 0x1) << 7;
200}
201static inline u32 psec_falcon_irqdest_host_ext_f(u32 v)
202{
203 return (v & 0xff) << 8;
204}
205static inline u32 psec_falcon_irqdest_target_gptmr_f(u32 v)
206{
207 return (v & 0x1) << 16;
208}
209static inline u32 psec_falcon_irqdest_target_wdtmr_f(u32 v)
210{
211 return (v & 0x1) << 17;
212}
213static inline u32 psec_falcon_irqdest_target_mthd_f(u32 v)
214{
215 return (v & 0x1) << 18;
216}
217static inline u32 psec_falcon_irqdest_target_ctxsw_f(u32 v)
218{
219 return (v & 0x1) << 19;
220}
221static inline u32 psec_falcon_irqdest_target_halt_f(u32 v)
222{
223 return (v & 0x1) << 20;
224}
225static inline u32 psec_falcon_irqdest_target_exterr_f(u32 v)
226{
227 return (v & 0x1) << 21;
228}
229static inline u32 psec_falcon_irqdest_target_swgen0_f(u32 v)
230{
231 return (v & 0x1) << 22;
232}
233static inline u32 psec_falcon_irqdest_target_swgen1_f(u32 v)
234{
235 return (v & 0x1) << 23;
236}
237static inline u32 psec_falcon_irqdest_target_ext_f(u32 v)
238{
239 return (v & 0xff) << 24;
240}
241static inline u32 psec_falcon_curctx_r(void)
242{
243 return 0x00087050;
244}
245static inline u32 psec_falcon_nxtctx_r(void)
246{
247 return 0x00087054;
248}
249static inline u32 psec_falcon_mailbox0_r(void)
250{
251 return 0x00087040;
252}
253static inline u32 psec_falcon_mailbox1_r(void)
254{
255 return 0x00087044;
256}
257static inline u32 psec_falcon_itfen_r(void)
258{
259 return 0x00087048;
260}
261static inline u32 psec_falcon_itfen_ctxen_enable_f(void)
262{
263 return 0x1;
264}
265static inline u32 psec_falcon_idlestate_r(void)
266{
267 return 0x0008704c;
268}
269static inline u32 psec_falcon_idlestate_falcon_busy_v(u32 r)
270{
271 return (r >> 0) & 0x1;
272}
273static inline u32 psec_falcon_idlestate_ext_busy_v(u32 r)
274{
275 return (r >> 1) & 0x7fff;
276}
277static inline u32 psec_falcon_os_r(void)
278{
279 return 0x00087080;
280}
281static inline u32 psec_falcon_engctl_r(void)
282{
283 return 0x000870a4;
284}
285static inline u32 psec_falcon_cpuctl_r(void)
286{
287 return 0x00087100;
288}
289static inline u32 psec_falcon_cpuctl_startcpu_f(u32 v)
290{
291 return (v & 0x1) << 1;
292}
293static inline u32 psec_falcon_cpuctl_halt_intr_f(u32 v)
294{
295 return (v & 0x1) << 4;
296}
297static inline u32 psec_falcon_cpuctl_halt_intr_m(void)
298{
299 return 0x1 << 4;
300}
301static inline u32 psec_falcon_cpuctl_halt_intr_v(u32 r)
302{
303 return (r >> 4) & 0x1;
304}
305static inline u32 psec_falcon_cpuctl_cpuctl_alias_en_f(u32 v)
306{
307 return (v & 0x1) << 6;
308}
309static inline u32 psec_falcon_cpuctl_cpuctl_alias_en_m(void)
310{
311 return 0x1 << 6;
312}
313static inline u32 psec_falcon_cpuctl_cpuctl_alias_en_v(u32 r)
314{
315 return (r >> 6) & 0x1;
316}
317static inline u32 psec_falcon_cpuctl_alias_r(void)
318{
319 return 0x00087130;
320}
321static inline u32 psec_falcon_cpuctl_alias_startcpu_f(u32 v)
322{
323 return (v & 0x1) << 1;
324}
325static inline u32 psec_falcon_imemc_r(u32 i)
326{
327 return 0x00087180 + i*16;
328}
329static inline u32 psec_falcon_imemc_offs_f(u32 v)
330{
331 return (v & 0x3f) << 2;
332}
333static inline u32 psec_falcon_imemc_blk_f(u32 v)
334{
335 return (v & 0xff) << 8;
336}
337static inline u32 psec_falcon_imemc_aincw_f(u32 v)
338{
339 return (v & 0x1) << 24;
340}
341static inline u32 psec_falcon_imemd_r(u32 i)
342{
343 return 0x00087184 + i*16;
344}
345static inline u32 psec_falcon_imemt_r(u32 i)
346{
347 return 0x00087188 + i*16;
348}
349static inline u32 psec_falcon_sctl_r(void)
350{
351 return 0x00087240;
352}
353static inline u32 psec_falcon_mmu_phys_sec_r(void)
354{
355 return 0x00100ce4;
356}
357static inline u32 psec_falcon_bootvec_r(void)
358{
359 return 0x00087104;
360}
361static inline u32 psec_falcon_bootvec_vec_f(u32 v)
362{
363 return (v & 0xffffffff) << 0;
364}
365static inline u32 psec_falcon_dmactl_r(void)
366{
367 return 0x0008710c;
368}
369static inline u32 psec_falcon_dmactl_dmem_scrubbing_m(void)
370{
371 return 0x1 << 1;
372}
373static inline u32 psec_falcon_dmactl_imem_scrubbing_m(void)
374{
375 return 0x1 << 2;
376}
377static inline u32 psec_falcon_dmactl_require_ctx_f(u32 v)
378{
379 return (v & 0x1) << 0;
380}
381static inline u32 psec_falcon_hwcfg_r(void)
382{
383 return 0x00087108;
384}
385static inline u32 psec_falcon_hwcfg_imem_size_v(u32 r)
386{
387 return (r >> 0) & 0x1ff;
388}
389static inline u32 psec_falcon_hwcfg_dmem_size_v(u32 r)
390{
391 return (r >> 9) & 0x1ff;
392}
393static inline u32 psec_falcon_dmatrfbase_r(void)
394{
395 return 0x00087110;
396}
397static inline u32 psec_falcon_dmatrfbase1_r(void)
398{
399 return 0x00087128;
400}
401static inline u32 psec_falcon_dmatrfmoffs_r(void)
402{
403 return 0x00087114;
404}
405static inline u32 psec_falcon_dmatrfcmd_r(void)
406{
407 return 0x00087118;
408}
409static inline u32 psec_falcon_dmatrfcmd_imem_f(u32 v)
410{
411 return (v & 0x1) << 4;
412}
413static inline u32 psec_falcon_dmatrfcmd_write_f(u32 v)
414{
415 return (v & 0x1) << 5;
416}
417static inline u32 psec_falcon_dmatrfcmd_size_f(u32 v)
418{
419 return (v & 0x7) << 8;
420}
421static inline u32 psec_falcon_dmatrfcmd_ctxdma_f(u32 v)
422{
423 return (v & 0x7) << 12;
424}
425static inline u32 psec_falcon_dmatrffboffs_r(void)
426{
427 return 0x0008711c;
428}
429static inline u32 psec_falcon_exterraddr_r(void)
430{
431 return 0x00087168;
432}
433static inline u32 psec_falcon_exterrstat_r(void)
434{
435 return 0x0008716c;
436}
437static inline u32 psec_falcon_exterrstat_valid_m(void)
438{
439 return 0x1 << 31;
440}
441static inline u32 psec_falcon_exterrstat_valid_v(u32 r)
442{
443 return (r >> 31) & 0x1;
444}
445static inline u32 psec_falcon_exterrstat_valid_true_v(void)
446{
447 return 0x00000001;
448}
449static inline u32 psec_sec2_falcon_icd_cmd_r(void)
450{
451 return 0x00087200;
452}
453static inline u32 psec_sec2_falcon_icd_cmd_opc_s(void)
454{
455 return 4;
456}
457static inline u32 psec_sec2_falcon_icd_cmd_opc_f(u32 v)
458{
459 return (v & 0xf) << 0;
460}
461static inline u32 psec_sec2_falcon_icd_cmd_opc_m(void)
462{
463 return 0xf << 0;
464}
465static inline u32 psec_sec2_falcon_icd_cmd_opc_v(u32 r)
466{
467 return (r >> 0) & 0xf;
468}
469static inline u32 psec_sec2_falcon_icd_cmd_opc_rreg_f(void)
470{
471 return 0x8;
472}
473static inline u32 psec_sec2_falcon_icd_cmd_opc_rstat_f(void)
474{
475 return 0xe;
476}
477static inline u32 psec_sec2_falcon_icd_cmd_idx_f(u32 v)
478{
479 return (v & 0x1f) << 8;
480}
481static inline u32 psec_sec2_falcon_icd_rdata_r(void)
482{
483 return 0x0008720c;
484}
485static inline u32 psec_falcon_dmemc_r(u32 i)
486{
487 return 0x000871c0 + i*8;
488}
489static inline u32 psec_falcon_dmemc_offs_f(u32 v)
490{
491 return (v & 0x3f) << 2;
492}
493static inline u32 psec_falcon_dmemc_offs_m(void)
494{
495 return 0x3f << 2;
496}
497static inline u32 psec_falcon_dmemc_blk_f(u32 v)
498{
499 return (v & 0xff) << 8;
500}
501static inline u32 psec_falcon_dmemc_blk_m(void)
502{
503 return 0xff << 8;
504}
505static inline u32 psec_falcon_dmemc_aincw_f(u32 v)
506{
507 return (v & 0x1) << 24;
508}
509static inline u32 psec_falcon_dmemc_aincr_f(u32 v)
510{
511 return (v & 0x1) << 25;
512}
513static inline u32 psec_falcon_dmemd_r(u32 i)
514{
515 return 0x000871c4 + i*8;
516}
517static inline u32 psec_falcon_debug1_r(void)
518{
519 return 0x00087090;
520}
521static inline u32 psec_falcon_debug1_ctxsw_mode_s(void)
522{
523 return 1;
524}
525static inline u32 psec_falcon_debug1_ctxsw_mode_f(u32 v)
526{
527 return (v & 0x1) << 16;
528}
529static inline u32 psec_falcon_debug1_ctxsw_mode_m(void)
530{
531 return 0x1 << 16;
532}
533static inline u32 psec_falcon_debug1_ctxsw_mode_v(u32 r)
534{
535 return (r >> 16) & 0x1;
536}
537static inline u32 psec_falcon_debug1_ctxsw_mode_init_f(void)
538{
539 return 0x0;
540}
541static inline u32 psec_fbif_transcfg_r(u32 i)
542{
543 return 0x00087600 + i*4;
544}
545static inline u32 psec_fbif_transcfg_target_local_fb_f(void)
546{
547 return 0x0;
548}
549static inline u32 psec_fbif_transcfg_target_coherent_sysmem_f(void)
550{
551 return 0x1;
552}
553static inline u32 psec_fbif_transcfg_target_noncoherent_sysmem_f(void)
554{
555 return 0x2;
556}
557static inline u32 psec_fbif_transcfg_mem_type_s(void)
558{
559 return 1;
560}
561static inline u32 psec_fbif_transcfg_mem_type_f(u32 v)
562{
563 return (v & 0x1) << 2;
564}
565static inline u32 psec_fbif_transcfg_mem_type_m(void)
566{
567 return 0x1 << 2;
568}
569static inline u32 psec_fbif_transcfg_mem_type_v(u32 r)
570{
571 return (r >> 2) & 0x1;
572}
573static inline u32 psec_fbif_transcfg_mem_type_virtual_f(void)
574{
575 return 0x0;
576}
577static inline u32 psec_fbif_transcfg_mem_type_physical_f(void)
578{
579 return 0x4;
580}
581static inline u32 psec_falcon_engine_r(void)
582{
583 return 0x000873c0;
584}
585static inline u32 psec_falcon_engine_reset_true_f(void)
586{
587 return 0x1;
588}
589static inline u32 psec_falcon_engine_reset_false_f(void)
590{
591 return 0x0;
592}
593static inline u32 psec_fbif_ctl_r(void)
594{
595 return 0x00087624;
596}
597static inline u32 psec_fbif_ctl_allow_phys_no_ctx_init_f(void)
598{
599 return 0x0;
600}
601static inline u32 psec_fbif_ctl_allow_phys_no_ctx_disallow_f(void)
602{
603 return 0x0;
604}
605static inline u32 psec_fbif_ctl_allow_phys_no_ctx_allow_f(void)
606{
607 return 0x80;
608}
609#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_pwr_gp106.h b/drivers/gpu/nvgpu/gp106/hw_pwr_gp106.h
new file mode 100644
index 00000000..b4dfea0d
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_pwr_gp106.h
@@ -0,0 +1,841 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_pwr_gp106_h_
51#define _hw_pwr_gp106_h_
52
53static inline u32 pwr_falcon_irqsset_r(void)
54{
55 return 0x0010a000;
56}
57static inline u32 pwr_falcon_irqsset_swgen0_set_f(void)
58{
59 return 0x40;
60}
61static inline u32 pwr_falcon_irqsclr_r(void)
62{
63 return 0x0010a004;
64}
65static inline u32 pwr_falcon_irqstat_r(void)
66{
67 return 0x0010a008;
68}
69static inline u32 pwr_falcon_irqstat_halt_true_f(void)
70{
71 return 0x10;
72}
73static inline u32 pwr_falcon_irqstat_exterr_true_f(void)
74{
75 return 0x20;
76}
77static inline u32 pwr_falcon_irqstat_swgen0_true_f(void)
78{
79 return 0x40;
80}
81static inline u32 pwr_falcon_irqmode_r(void)
82{
83 return 0x0010a00c;
84}
85static inline u32 pwr_falcon_irqmset_r(void)
86{
87 return 0x0010a010;
88}
89static inline u32 pwr_falcon_irqmset_gptmr_f(u32 v)
90{
91 return (v & 0x1) << 0;
92}
93static inline u32 pwr_falcon_irqmset_wdtmr_f(u32 v)
94{
95 return (v & 0x1) << 1;
96}
97static inline u32 pwr_falcon_irqmset_mthd_f(u32 v)
98{
99 return (v & 0x1) << 2;
100}
101static inline u32 pwr_falcon_irqmset_ctxsw_f(u32 v)
102{
103 return (v & 0x1) << 3;
104}
105static inline u32 pwr_falcon_irqmset_halt_f(u32 v)
106{
107 return (v & 0x1) << 4;
108}
109static inline u32 pwr_falcon_irqmset_exterr_f(u32 v)
110{
111 return (v & 0x1) << 5;
112}
113static inline u32 pwr_falcon_irqmset_swgen0_f(u32 v)
114{
115 return (v & 0x1) << 6;
116}
117static inline u32 pwr_falcon_irqmset_swgen1_f(u32 v)
118{
119 return (v & 0x1) << 7;
120}
121static inline u32 pwr_falcon_irqmclr_r(void)
122{
123 return 0x0010a014;
124}
125static inline u32 pwr_falcon_irqmclr_gptmr_f(u32 v)
126{
127 return (v & 0x1) << 0;
128}
129static inline u32 pwr_falcon_irqmclr_wdtmr_f(u32 v)
130{
131 return (v & 0x1) << 1;
132}
133static inline u32 pwr_falcon_irqmclr_mthd_f(u32 v)
134{
135 return (v & 0x1) << 2;
136}
137static inline u32 pwr_falcon_irqmclr_ctxsw_f(u32 v)
138{
139 return (v & 0x1) << 3;
140}
141static inline u32 pwr_falcon_irqmclr_halt_f(u32 v)
142{
143 return (v & 0x1) << 4;
144}
145static inline u32 pwr_falcon_irqmclr_exterr_f(u32 v)
146{
147 return (v & 0x1) << 5;
148}
149static inline u32 pwr_falcon_irqmclr_swgen0_f(u32 v)
150{
151 return (v & 0x1) << 6;
152}
153static inline u32 pwr_falcon_irqmclr_swgen1_f(u32 v)
154{
155 return (v & 0x1) << 7;
156}
157static inline u32 pwr_falcon_irqmclr_ext_f(u32 v)
158{
159 return (v & 0xff) << 8;
160}
161static inline u32 pwr_falcon_irqmask_r(void)
162{
163 return 0x0010a018;
164}
165static inline u32 pwr_falcon_irqdest_r(void)
166{
167 return 0x0010a01c;
168}
169static inline u32 pwr_falcon_irqdest_host_gptmr_f(u32 v)
170{
171 return (v & 0x1) << 0;
172}
173static inline u32 pwr_falcon_irqdest_host_wdtmr_f(u32 v)
174{
175 return (v & 0x1) << 1;
176}
177static inline u32 pwr_falcon_irqdest_host_mthd_f(u32 v)
178{
179 return (v & 0x1) << 2;
180}
181static inline u32 pwr_falcon_irqdest_host_ctxsw_f(u32 v)
182{
183 return (v & 0x1) << 3;
184}
185static inline u32 pwr_falcon_irqdest_host_halt_f(u32 v)
186{
187 return (v & 0x1) << 4;
188}
189static inline u32 pwr_falcon_irqdest_host_exterr_f(u32 v)
190{
191 return (v & 0x1) << 5;
192}
193static inline u32 pwr_falcon_irqdest_host_swgen0_f(u32 v)
194{
195 return (v & 0x1) << 6;
196}
197static inline u32 pwr_falcon_irqdest_host_swgen1_f(u32 v)
198{
199 return (v & 0x1) << 7;
200}
201static inline u32 pwr_falcon_irqdest_host_ext_f(u32 v)
202{
203 return (v & 0xff) << 8;
204}
205static inline u32 pwr_falcon_irqdest_target_gptmr_f(u32 v)
206{
207 return (v & 0x1) << 16;
208}
209static inline u32 pwr_falcon_irqdest_target_wdtmr_f(u32 v)
210{
211 return (v & 0x1) << 17;
212}
213static inline u32 pwr_falcon_irqdest_target_mthd_f(u32 v)
214{
215 return (v & 0x1) << 18;
216}
217static inline u32 pwr_falcon_irqdest_target_ctxsw_f(u32 v)
218{
219 return (v & 0x1) << 19;
220}
221static inline u32 pwr_falcon_irqdest_target_halt_f(u32 v)
222{
223 return (v & 0x1) << 20;
224}
225static inline u32 pwr_falcon_irqdest_target_exterr_f(u32 v)
226{
227 return (v & 0x1) << 21;
228}
229static inline u32 pwr_falcon_irqdest_target_swgen0_f(u32 v)
230{
231 return (v & 0x1) << 22;
232}
233static inline u32 pwr_falcon_irqdest_target_swgen1_f(u32 v)
234{
235 return (v & 0x1) << 23;
236}
237static inline u32 pwr_falcon_irqdest_target_ext_f(u32 v)
238{
239 return (v & 0xff) << 24;
240}
241static inline u32 pwr_falcon_curctx_r(void)
242{
243 return 0x0010a050;
244}
245static inline u32 pwr_falcon_nxtctx_r(void)
246{
247 return 0x0010a054;
248}
249static inline u32 pwr_falcon_mailbox0_r(void)
250{
251 return 0x0010a040;
252}
253static inline u32 pwr_falcon_mailbox1_r(void)
254{
255 return 0x0010a044;
256}
257static inline u32 pwr_falcon_itfen_r(void)
258{
259 return 0x0010a048;
260}
261static inline u32 pwr_falcon_itfen_ctxen_enable_f(void)
262{
263 return 0x1;
264}
265static inline u32 pwr_falcon_idlestate_r(void)
266{
267 return 0x0010a04c;
268}
269static inline u32 pwr_falcon_idlestate_falcon_busy_v(u32 r)
270{
271 return (r >> 0) & 0x1;
272}
273static inline u32 pwr_falcon_idlestate_ext_busy_v(u32 r)
274{
275 return (r >> 1) & 0x7fff;
276}
277static inline u32 pwr_falcon_os_r(void)
278{
279 return 0x0010a080;
280}
281static inline u32 pwr_falcon_engctl_r(void)
282{
283 return 0x0010a0a4;
284}
285static inline u32 pwr_falcon_cpuctl_r(void)
286{
287 return 0x0010a100;
288}
289static inline u32 pwr_falcon_cpuctl_startcpu_f(u32 v)
290{
291 return (v & 0x1) << 1;
292}
293static inline u32 pwr_falcon_cpuctl_halt_intr_f(u32 v)
294{
295 return (v & 0x1) << 4;
296}
297static inline u32 pwr_falcon_cpuctl_halt_intr_m(void)
298{
299 return 0x1 << 4;
300}
301static inline u32 pwr_falcon_cpuctl_halt_intr_v(u32 r)
302{
303 return (r >> 4) & 0x1;
304}
305static inline u32 pwr_falcon_cpuctl_cpuctl_alias_en_f(u32 v)
306{
307 return (v & 0x1) << 6;
308}
309static inline u32 pwr_falcon_cpuctl_cpuctl_alias_en_m(void)
310{
311 return 0x1 << 6;
312}
313static inline u32 pwr_falcon_cpuctl_cpuctl_alias_en_v(u32 r)
314{
315 return (r >> 6) & 0x1;
316}
317static inline u32 pwr_falcon_cpuctl_alias_r(void)
318{
319 return 0x0010a130;
320}
321static inline u32 pwr_falcon_cpuctl_alias_startcpu_f(u32 v)
322{
323 return (v & 0x1) << 1;
324}
325static inline u32 pwr_pmu_scpctl_stat_r(void)
326{
327 return 0x0010ac08;
328}
329static inline u32 pwr_pmu_scpctl_stat_debug_mode_f(u32 v)
330{
331 return (v & 0x1) << 20;
332}
333static inline u32 pwr_pmu_scpctl_stat_debug_mode_m(void)
334{
335 return 0x1 << 20;
336}
337static inline u32 pwr_pmu_scpctl_stat_debug_mode_v(u32 r)
338{
339 return (r >> 20) & 0x1;
340}
341static inline u32 pwr_falcon_imemc_r(u32 i)
342{
343 return 0x0010a180 + i*16;
344}
345static inline u32 pwr_falcon_imemc_offs_f(u32 v)
346{
347 return (v & 0x3f) << 2;
348}
349static inline u32 pwr_falcon_imemc_blk_f(u32 v)
350{
351 return (v & 0xff) << 8;
352}
353static inline u32 pwr_falcon_imemc_aincw_f(u32 v)
354{
355 return (v & 0x1) << 24;
356}
357static inline u32 pwr_falcon_imemd_r(u32 i)
358{
359 return 0x0010a184 + i*16;
360}
361static inline u32 pwr_falcon_imemt_r(u32 i)
362{
363 return 0x0010a188 + i*16;
364}
365static inline u32 pwr_falcon_sctl_r(void)
366{
367 return 0x0010a240;
368}
369static inline u32 pwr_falcon_mmu_phys_sec_r(void)
370{
371 return 0x00100ce4;
372}
373static inline u32 pwr_falcon_bootvec_r(void)
374{
375 return 0x0010a104;
376}
377static inline u32 pwr_falcon_bootvec_vec_f(u32 v)
378{
379 return (v & 0xffffffff) << 0;
380}
381static inline u32 pwr_falcon_dmactl_r(void)
382{
383 return 0x0010a10c;
384}
385static inline u32 pwr_falcon_dmactl_dmem_scrubbing_m(void)
386{
387 return 0x1 << 1;
388}
389static inline u32 pwr_falcon_dmactl_imem_scrubbing_m(void)
390{
391 return 0x1 << 2;
392}
393static inline u32 pwr_falcon_dmactl_require_ctx_f(u32 v)
394{
395 return (v & 0x1) << 0;
396}
397static inline u32 pwr_falcon_hwcfg_r(void)
398{
399 return 0x0010a108;
400}
401static inline u32 pwr_falcon_hwcfg_imem_size_v(u32 r)
402{
403 return (r >> 0) & 0x1ff;
404}
405static inline u32 pwr_falcon_hwcfg_dmem_size_v(u32 r)
406{
407 return (r >> 9) & 0x1ff;
408}
409static inline u32 pwr_falcon_dmatrfbase_r(void)
410{
411 return 0x0010a110;
412}
413static inline u32 pwr_falcon_dmatrfbase1_r(void)
414{
415 return 0x0010a128;
416}
417static inline u32 pwr_falcon_dmatrfmoffs_r(void)
418{
419 return 0x0010a114;
420}
421static inline u32 pwr_falcon_dmatrfcmd_r(void)
422{
423 return 0x0010a118;
424}
425static inline u32 pwr_falcon_dmatrfcmd_imem_f(u32 v)
426{
427 return (v & 0x1) << 4;
428}
429static inline u32 pwr_falcon_dmatrfcmd_write_f(u32 v)
430{
431 return (v & 0x1) << 5;
432}
433static inline u32 pwr_falcon_dmatrfcmd_size_f(u32 v)
434{
435 return (v & 0x7) << 8;
436}
437static inline u32 pwr_falcon_dmatrfcmd_ctxdma_f(u32 v)
438{
439 return (v & 0x7) << 12;
440}
441static inline u32 pwr_falcon_dmatrffboffs_r(void)
442{
443 return 0x0010a11c;
444}
445static inline u32 pwr_falcon_exterraddr_r(void)
446{
447 return 0x0010a168;
448}
449static inline u32 pwr_falcon_exterrstat_r(void)
450{
451 return 0x0010a16c;
452}
453static inline u32 pwr_falcon_exterrstat_valid_m(void)
454{
455 return 0x1 << 31;
456}
457static inline u32 pwr_falcon_exterrstat_valid_v(u32 r)
458{
459 return (r >> 31) & 0x1;
460}
461static inline u32 pwr_falcon_exterrstat_valid_true_v(void)
462{
463 return 0x00000001;
464}
465static inline u32 pwr_pmu_falcon_icd_cmd_r(void)
466{
467 return 0x0010a200;
468}
469static inline u32 pwr_pmu_falcon_icd_cmd_opc_s(void)
470{
471 return 4;
472}
473static inline u32 pwr_pmu_falcon_icd_cmd_opc_f(u32 v)
474{
475 return (v & 0xf) << 0;
476}
477static inline u32 pwr_pmu_falcon_icd_cmd_opc_m(void)
478{
479 return 0xf << 0;
480}
481static inline u32 pwr_pmu_falcon_icd_cmd_opc_v(u32 r)
482{
483 return (r >> 0) & 0xf;
484}
485static inline u32 pwr_pmu_falcon_icd_cmd_opc_rreg_f(void)
486{
487 return 0x8;
488}
489static inline u32 pwr_pmu_falcon_icd_cmd_opc_rstat_f(void)
490{
491 return 0xe;
492}
493static inline u32 pwr_pmu_falcon_icd_cmd_idx_f(u32 v)
494{
495 return (v & 0x1f) << 8;
496}
497static inline u32 pwr_pmu_falcon_icd_rdata_r(void)
498{
499 return 0x0010a20c;
500}
501static inline u32 pwr_falcon_dmemc_r(u32 i)
502{
503 return 0x0010a1c0 + i*8;
504}
505static inline u32 pwr_falcon_dmemc_offs_f(u32 v)
506{
507 return (v & 0x3f) << 2;
508}
509static inline u32 pwr_falcon_dmemc_offs_m(void)
510{
511 return 0x3f << 2;
512}
513static inline u32 pwr_falcon_dmemc_blk_f(u32 v)
514{
515 return (v & 0xff) << 8;
516}
517static inline u32 pwr_falcon_dmemc_blk_m(void)
518{
519 return 0xff << 8;
520}
521static inline u32 pwr_falcon_dmemc_aincw_f(u32 v)
522{
523 return (v & 0x1) << 24;
524}
525static inline u32 pwr_falcon_dmemc_aincr_f(u32 v)
526{
527 return (v & 0x1) << 25;
528}
529static inline u32 pwr_falcon_dmemd_r(u32 i)
530{
531 return 0x0010a1c4 + i*8;
532}
533static inline u32 pwr_pmu_new_instblk_r(void)
534{
535 return 0x0010a480;
536}
537static inline u32 pwr_pmu_new_instblk_ptr_f(u32 v)
538{
539 return (v & 0xfffffff) << 0;
540}
541static inline u32 pwr_pmu_new_instblk_target_fb_f(void)
542{
543 return 0x0;
544}
545static inline u32 pwr_pmu_new_instblk_target_sys_coh_f(void)
546{
547 return 0x20000000;
548}
549static inline u32 pwr_pmu_new_instblk_target_sys_ncoh_f(void)
550{
551 return 0x30000000;
552}
553static inline u32 pwr_pmu_new_instblk_valid_f(u32 v)
554{
555 return (v & 0x1) << 30;
556}
557static inline u32 pwr_pmu_mutex_id_r(void)
558{
559 return 0x0010a488;
560}
561static inline u32 pwr_pmu_mutex_id_value_v(u32 r)
562{
563 return (r >> 0) & 0xff;
564}
565static inline u32 pwr_pmu_mutex_id_value_init_v(void)
566{
567 return 0x00000000;
568}
569static inline u32 pwr_pmu_mutex_id_value_not_avail_v(void)
570{
571 return 0x000000ff;
572}
573static inline u32 pwr_pmu_mutex_id_release_r(void)
574{
575 return 0x0010a48c;
576}
577static inline u32 pwr_pmu_mutex_id_release_value_f(u32 v)
578{
579 return (v & 0xff) << 0;
580}
581static inline u32 pwr_pmu_mutex_id_release_value_m(void)
582{
583 return 0xff << 0;
584}
585static inline u32 pwr_pmu_mutex_id_release_value_init_v(void)
586{
587 return 0x00000000;
588}
589static inline u32 pwr_pmu_mutex_id_release_value_init_f(void)
590{
591 return 0x0;
592}
593static inline u32 pwr_pmu_mutex_r(u32 i)
594{
595 return 0x0010a580 + i*4;
596}
597static inline u32 pwr_pmu_mutex__size_1_v(void)
598{
599 return 0x00000010;
600}
601static inline u32 pwr_pmu_mutex_value_f(u32 v)
602{
603 return (v & 0xff) << 0;
604}
605static inline u32 pwr_pmu_mutex_value_v(u32 r)
606{
607 return (r >> 0) & 0xff;
608}
609static inline u32 pwr_pmu_mutex_value_initial_lock_f(void)
610{
611 return 0x0;
612}
613static inline u32 pwr_pmu_queue_head_r(u32 i)
614{
615 return 0x0010a4a0 + i*4;
616}
617static inline u32 pwr_pmu_queue_head__size_1_v(void)
618{
619 return 0x00000004;
620}
621static inline u32 pwr_pmu_queue_head_address_f(u32 v)
622{
623 return (v & 0xffffffff) << 0;
624}
625static inline u32 pwr_pmu_queue_head_address_v(u32 r)
626{
627 return (r >> 0) & 0xffffffff;
628}
629static inline u32 pwr_pmu_queue_tail_r(u32 i)
630{
631 return 0x0010a4b0 + i*4;
632}
633static inline u32 pwr_pmu_queue_tail__size_1_v(void)
634{
635 return 0x00000004;
636}
637static inline u32 pwr_pmu_queue_tail_address_f(u32 v)
638{
639 return (v & 0xffffffff) << 0;
640}
641static inline u32 pwr_pmu_queue_tail_address_v(u32 r)
642{
643 return (r >> 0) & 0xffffffff;
644}
645static inline u32 pwr_pmu_msgq_head_r(void)
646{
647 return 0x0010a4c8;
648}
649static inline u32 pwr_pmu_msgq_head_val_f(u32 v)
650{
651 return (v & 0xffffffff) << 0;
652}
653static inline u32 pwr_pmu_msgq_head_val_v(u32 r)
654{
655 return (r >> 0) & 0xffffffff;
656}
657static inline u32 pwr_pmu_msgq_tail_r(void)
658{
659 return 0x0010a4cc;
660}
661static inline u32 pwr_pmu_msgq_tail_val_f(u32 v)
662{
663 return (v & 0xffffffff) << 0;
664}
665static inline u32 pwr_pmu_msgq_tail_val_v(u32 r)
666{
667 return (r >> 0) & 0xffffffff;
668}
669static inline u32 pwr_pmu_idle_mask_r(u32 i)
670{
671 return 0x0010a504 + i*16;
672}
673static inline u32 pwr_pmu_idle_mask_gr_enabled_f(void)
674{
675 return 0x1;
676}
677static inline u32 pwr_pmu_idle_mask_ce_2_enabled_f(void)
678{
679 return 0x200000;
680}
681static inline u32 pwr_pmu_idle_count_r(u32 i)
682{
683 return 0x0010a508 + i*16;
684}
685static inline u32 pwr_pmu_idle_count_value_f(u32 v)
686{
687 return (v & 0x7fffffff) << 0;
688}
689static inline u32 pwr_pmu_idle_count_value_v(u32 r)
690{
691 return (r >> 0) & 0x7fffffff;
692}
693static inline u32 pwr_pmu_idle_count_reset_f(u32 v)
694{
695 return (v & 0x1) << 31;
696}
697static inline u32 pwr_pmu_idle_ctrl_r(u32 i)
698{
699 return 0x0010a50c + i*16;
700}
701static inline u32 pwr_pmu_idle_ctrl_value_m(void)
702{
703 return 0x3 << 0;
704}
705static inline u32 pwr_pmu_idle_ctrl_value_busy_f(void)
706{
707 return 0x2;
708}
709static inline u32 pwr_pmu_idle_ctrl_value_always_f(void)
710{
711 return 0x3;
712}
713static inline u32 pwr_pmu_idle_ctrl_filter_m(void)
714{
715 return 0x1 << 2;
716}
717static inline u32 pwr_pmu_idle_ctrl_filter_disabled_f(void)
718{
719 return 0x0;
720}
721static inline u32 pwr_pmu_idle_mask_supp_r(u32 i)
722{
723 return 0x0010a9f0 + i*8;
724}
725static inline u32 pwr_pmu_idle_mask_1_supp_r(u32 i)
726{
727 return 0x0010a9f4 + i*8;
728}
729static inline u32 pwr_pmu_idle_ctrl_supp_r(u32 i)
730{
731 return 0x0010aa30 + i*8;
732}
733static inline u32 pwr_pmu_debug_r(u32 i)
734{
735 return 0x0010a5c0 + i*4;
736}
737static inline u32 pwr_pmu_debug__size_1_v(void)
738{
739 return 0x00000004;
740}
741static inline u32 pwr_pmu_mailbox_r(u32 i)
742{
743 return 0x0010a450 + i*4;
744}
745static inline u32 pwr_pmu_mailbox__size_1_v(void)
746{
747 return 0x0000000c;
748}
749static inline u32 pwr_pmu_bar0_addr_r(void)
750{
751 return 0x0010a7a0;
752}
753static inline u32 pwr_pmu_bar0_data_r(void)
754{
755 return 0x0010a7a4;
756}
757static inline u32 pwr_pmu_bar0_ctl_r(void)
758{
759 return 0x0010a7ac;
760}
761static inline u32 pwr_pmu_bar0_timeout_r(void)
762{
763 return 0x0010a7a8;
764}
765static inline u32 pwr_pmu_bar0_fecs_error_r(void)
766{
767 return 0x0010a988;
768}
769static inline u32 pwr_pmu_bar0_error_status_r(void)
770{
771 return 0x0010a7b0;
772}
773static inline u32 pwr_pmu_pg_idlefilth_r(u32 i)
774{
775 return 0x0010a6c0 + i*4;
776}
777static inline u32 pwr_pmu_pg_ppuidlefilth_r(u32 i)
778{
779 return 0x0010a6e8 + i*4;
780}
781static inline u32 pwr_pmu_pg_idle_cnt_r(u32 i)
782{
783 return 0x0010a710 + i*4;
784}
785static inline u32 pwr_pmu_pg_intren_r(u32 i)
786{
787 return 0x0010a760 + i*4;
788}
789static inline u32 pwr_fbif_transcfg_r(u32 i)
790{
791 return 0x0010ae00 + i*4;
792}
793static inline u32 pwr_fbif_transcfg_target_local_fb_f(void)
794{
795 return 0x0;
796}
797static inline u32 pwr_fbif_transcfg_target_coherent_sysmem_f(void)
798{
799 return 0x1;
800}
801static inline u32 pwr_fbif_transcfg_target_noncoherent_sysmem_f(void)
802{
803 return 0x2;
804}
805static inline u32 pwr_fbif_transcfg_mem_type_s(void)
806{
807 return 1;
808}
809static inline u32 pwr_fbif_transcfg_mem_type_f(u32 v)
810{
811 return (v & 0x1) << 2;
812}
813static inline u32 pwr_fbif_transcfg_mem_type_m(void)
814{
815 return 0x1 << 2;
816}
817static inline u32 pwr_fbif_transcfg_mem_type_v(u32 r)
818{
819 return (r >> 2) & 0x1;
820}
821static inline u32 pwr_fbif_transcfg_mem_type_virtual_f(void)
822{
823 return 0x0;
824}
825static inline u32 pwr_fbif_transcfg_mem_type_physical_f(void)
826{
827 return 0x4;
828}
829static inline u32 pwr_falcon_engine_r(void)
830{
831 return 0x0010a3c0;
832}
833static inline u32 pwr_falcon_engine_reset_true_f(void)
834{
835 return 0x1;
836}
837static inline u32 pwr_falcon_engine_reset_false_f(void)
838{
839 return 0x0;
840}
841#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_ram_gp106.h b/drivers/gpu/nvgpu/gp106/hw_ram_gp106.h
new file mode 100644
index 00000000..eb02ac28
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_ram_gp106.h
@@ -0,0 +1,481 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ram_gp106_h_
51#define _hw_ram_gp106_h_
52
53static inline u32 ram_in_ramfc_s(void)
54{
55 return 4096;
56}
57static inline u32 ram_in_ramfc_w(void)
58{
59 return 0;
60}
61static inline u32 ram_in_page_dir_base_target_f(u32 v)
62{
63 return (v & 0x3) << 0;
64}
65static inline u32 ram_in_page_dir_base_target_w(void)
66{
67 return 128;
68}
69static inline u32 ram_in_page_dir_base_target_vid_mem_f(void)
70{
71 return 0x0;
72}
73static inline u32 ram_in_page_dir_base_target_sys_mem_coh_f(void)
74{
75 return 0x2;
76}
77static inline u32 ram_in_page_dir_base_target_sys_mem_ncoh_f(void)
78{
79 return 0x3;
80}
81static inline u32 ram_in_page_dir_base_vol_w(void)
82{
83 return 128;
84}
85static inline u32 ram_in_page_dir_base_vol_true_f(void)
86{
87 return 0x4;
88}
89static inline u32 ram_in_page_dir_base_fault_replay_tex_f(u32 v)
90{
91 return (v & 0x1) << 4;
92}
93static inline u32 ram_in_page_dir_base_fault_replay_tex_m(void)
94{
95 return 0x1 << 4;
96}
97static inline u32 ram_in_page_dir_base_fault_replay_tex_w(void)
98{
99 return 128;
100}
101static inline u32 ram_in_page_dir_base_fault_replay_tex_true_f(void)
102{
103 return 0x10;
104}
105static inline u32 ram_in_page_dir_base_fault_replay_gcc_f(u32 v)
106{
107 return (v & 0x1) << 5;
108}
109static inline u32 ram_in_page_dir_base_fault_replay_gcc_m(void)
110{
111 return 0x1 << 5;
112}
113static inline u32 ram_in_page_dir_base_fault_replay_gcc_w(void)
114{
115 return 128;
116}
117static inline u32 ram_in_page_dir_base_fault_replay_gcc_true_f(void)
118{
119 return 0x20;
120}
121static inline u32 ram_in_big_page_size_f(u32 v)
122{
123 return (v & 0x1) << 11;
124}
125static inline u32 ram_in_big_page_size_m(void)
126{
127 return 0x1 << 11;
128}
129static inline u32 ram_in_big_page_size_w(void)
130{
131 return 128;
132}
133static inline u32 ram_in_big_page_size_128kb_f(void)
134{
135 return 0x0;
136}
137static inline u32 ram_in_big_page_size_64kb_f(void)
138{
139 return 0x800;
140}
141static inline u32 ram_in_page_dir_base_lo_f(u32 v)
142{
143 return (v & 0xfffff) << 12;
144}
145static inline u32 ram_in_page_dir_base_lo_w(void)
146{
147 return 128;
148}
149static inline u32 ram_in_page_dir_base_hi_f(u32 v)
150{
151 return (v & 0xffffffff) << 0;
152}
153static inline u32 ram_in_page_dir_base_hi_w(void)
154{
155 return 129;
156}
157static inline u32 ram_in_adr_limit_lo_f(u32 v)
158{
159 return (v & 0xfffff) << 12;
160}
161static inline u32 ram_in_adr_limit_lo_w(void)
162{
163 return 130;
164}
165static inline u32 ram_in_adr_limit_hi_f(u32 v)
166{
167 return (v & 0xffffffff) << 0;
168}
169static inline u32 ram_in_adr_limit_hi_w(void)
170{
171 return 131;
172}
173static inline u32 ram_in_engine_cs_w(void)
174{
175 return 132;
176}
177static inline u32 ram_in_engine_cs_wfi_v(void)
178{
179 return 0x00000000;
180}
181static inline u32 ram_in_engine_cs_wfi_f(void)
182{
183 return 0x0;
184}
185static inline u32 ram_in_engine_cs_fg_v(void)
186{
187 return 0x00000001;
188}
189static inline u32 ram_in_engine_cs_fg_f(void)
190{
191 return 0x8;
192}
193static inline u32 ram_in_gr_cs_w(void)
194{
195 return 132;
196}
197static inline u32 ram_in_gr_cs_wfi_f(void)
198{
199 return 0x0;
200}
201static inline u32 ram_in_gr_wfi_target_w(void)
202{
203 return 132;
204}
205static inline u32 ram_in_gr_wfi_mode_w(void)
206{
207 return 132;
208}
209static inline u32 ram_in_gr_wfi_mode_physical_v(void)
210{
211 return 0x00000000;
212}
213static inline u32 ram_in_gr_wfi_mode_physical_f(void)
214{
215 return 0x0;
216}
217static inline u32 ram_in_gr_wfi_mode_virtual_v(void)
218{
219 return 0x00000001;
220}
221static inline u32 ram_in_gr_wfi_mode_virtual_f(void)
222{
223 return 0x4;
224}
225static inline u32 ram_in_gr_wfi_ptr_lo_f(u32 v)
226{
227 return (v & 0xfffff) << 12;
228}
229static inline u32 ram_in_gr_wfi_ptr_lo_w(void)
230{
231 return 132;
232}
233static inline u32 ram_in_gr_wfi_ptr_hi_f(u32 v)
234{
235 return (v & 0xff) << 0;
236}
237static inline u32 ram_in_gr_wfi_ptr_hi_w(void)
238{
239 return 133;
240}
241static inline u32 ram_in_base_shift_v(void)
242{
243 return 0x0000000c;
244}
245static inline u32 ram_in_alloc_size_v(void)
246{
247 return 0x00001000;
248}
249static inline u32 ram_fc_size_val_v(void)
250{
251 return 0x00000200;
252}
253static inline u32 ram_fc_gp_put_w(void)
254{
255 return 0;
256}
257static inline u32 ram_fc_userd_w(void)
258{
259 return 2;
260}
261static inline u32 ram_fc_userd_hi_w(void)
262{
263 return 3;
264}
265static inline u32 ram_fc_signature_w(void)
266{
267 return 4;
268}
269static inline u32 ram_fc_gp_get_w(void)
270{
271 return 5;
272}
273static inline u32 ram_fc_pb_get_w(void)
274{
275 return 6;
276}
277static inline u32 ram_fc_pb_get_hi_w(void)
278{
279 return 7;
280}
281static inline u32 ram_fc_pb_top_level_get_w(void)
282{
283 return 8;
284}
285static inline u32 ram_fc_pb_top_level_get_hi_w(void)
286{
287 return 9;
288}
289static inline u32 ram_fc_acquire_w(void)
290{
291 return 12;
292}
293static inline u32 ram_fc_semaphorea_w(void)
294{
295 return 14;
296}
297static inline u32 ram_fc_semaphoreb_w(void)
298{
299 return 15;
300}
301static inline u32 ram_fc_semaphorec_w(void)
302{
303 return 16;
304}
305static inline u32 ram_fc_semaphored_w(void)
306{
307 return 17;
308}
309static inline u32 ram_fc_gp_base_w(void)
310{
311 return 18;
312}
313static inline u32 ram_fc_gp_base_hi_w(void)
314{
315 return 19;
316}
317static inline u32 ram_fc_gp_fetch_w(void)
318{
319 return 20;
320}
321static inline u32 ram_fc_pb_fetch_w(void)
322{
323 return 21;
324}
325static inline u32 ram_fc_pb_fetch_hi_w(void)
326{
327 return 22;
328}
329static inline u32 ram_fc_pb_put_w(void)
330{
331 return 23;
332}
333static inline u32 ram_fc_pb_put_hi_w(void)
334{
335 return 24;
336}
337static inline u32 ram_fc_pb_header_w(void)
338{
339 return 33;
340}
341static inline u32 ram_fc_pb_count_w(void)
342{
343 return 34;
344}
345static inline u32 ram_fc_subdevice_w(void)
346{
347 return 37;
348}
349static inline u32 ram_fc_formats_w(void)
350{
351 return 39;
352}
353static inline u32 ram_fc_target_w(void)
354{
355 return 43;
356}
357static inline u32 ram_fc_hce_ctrl_w(void)
358{
359 return 57;
360}
361static inline u32 ram_fc_chid_w(void)
362{
363 return 58;
364}
365static inline u32 ram_fc_chid_id_f(u32 v)
366{
367 return (v & 0xfff) << 0;
368}
369static inline u32 ram_fc_chid_id_w(void)
370{
371 return 0;
372}
373static inline u32 ram_fc_config_w(void)
374{
375 return 61;
376}
377static inline u32 ram_fc_runlist_timeslice_w(void)
378{
379 return 62;
380}
381static inline u32 ram_userd_base_shift_v(void)
382{
383 return 0x00000009;
384}
385static inline u32 ram_userd_chan_size_v(void)
386{
387 return 0x00000200;
388}
389static inline u32 ram_userd_put_w(void)
390{
391 return 16;
392}
393static inline u32 ram_userd_get_w(void)
394{
395 return 17;
396}
397static inline u32 ram_userd_ref_w(void)
398{
399 return 18;
400}
401static inline u32 ram_userd_put_hi_w(void)
402{
403 return 19;
404}
405static inline u32 ram_userd_ref_threshold_w(void)
406{
407 return 20;
408}
409static inline u32 ram_userd_top_level_get_w(void)
410{
411 return 22;
412}
413static inline u32 ram_userd_top_level_get_hi_w(void)
414{
415 return 23;
416}
417static inline u32 ram_userd_get_hi_w(void)
418{
419 return 24;
420}
421static inline u32 ram_userd_gp_get_w(void)
422{
423 return 34;
424}
425static inline u32 ram_userd_gp_put_w(void)
426{
427 return 35;
428}
429static inline u32 ram_userd_gp_top_level_get_w(void)
430{
431 return 22;
432}
433static inline u32 ram_userd_gp_top_level_get_hi_w(void)
434{
435 return 23;
436}
437static inline u32 ram_rl_entry_size_v(void)
438{
439 return 0x00000008;
440}
441static inline u32 ram_rl_entry_chid_f(u32 v)
442{
443 return (v & 0xfff) << 0;
444}
445static inline u32 ram_rl_entry_id_f(u32 v)
446{
447 return (v & 0xfff) << 0;
448}
449static inline u32 ram_rl_entry_type_f(u32 v)
450{
451 return (v & 0x1) << 13;
452}
453static inline u32 ram_rl_entry_type_chid_f(void)
454{
455 return 0x0;
456}
457static inline u32 ram_rl_entry_type_tsg_f(void)
458{
459 return 0x2000;
460}
461static inline u32 ram_rl_entry_timeslice_scale_f(u32 v)
462{
463 return (v & 0xf) << 14;
464}
465static inline u32 ram_rl_entry_timeslice_scale_3_f(void)
466{
467 return 0xc000;
468}
469static inline u32 ram_rl_entry_timeslice_timeout_f(u32 v)
470{
471 return (v & 0xff) << 18;
472}
473static inline u32 ram_rl_entry_timeslice_timeout_128_f(void)
474{
475 return 0x2000000;
476}
477static inline u32 ram_rl_entry_tsg_length_f(u32 v)
478{
479 return (v & 0x3f) << 26;
480}
481#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_therm_gp106.h b/drivers/gpu/nvgpu/gp106/hw_therm_gp106.h
new file mode 100644
index 00000000..36ffcc7a
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_therm_gp106.h
@@ -0,0 +1,177 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_therm_gp106_h_
51#define _hw_therm_gp106_h_
52
53static inline u32 therm_temp_sensor_tsense_r(void)
54{
55 return 0x00020460;
56}
57static inline u32 therm_temp_sensor_tsense_fixed_point_f(u32 v)
58{
59 return (v & 0x3fff) << 3;
60}
61static inline u32 therm_temp_sensor_tsense_fixed_point_m(void)
62{
63 return 0x3fff << 3;
64}
65static inline u32 therm_temp_sensor_tsense_fixed_point_v(u32 r)
66{
67 return (r >> 3) & 0x3fff;
68}
69static inline u32 therm_temp_sensor_tsense_fixed_point_min_v(void)
70{
71 return 0x00003b00;
72}
73static inline u32 therm_temp_sensor_tsense_fixed_point_max_v(void)
74{
75 return 0x000010e0;
76}
77static inline u32 therm_temp_sensor_tsense_state_f(u32 v)
78{
79 return (v & 0x3) << 29;
80}
81static inline u32 therm_temp_sensor_tsense_state_m(void)
82{
83 return 0x3 << 29;
84}
85static inline u32 therm_temp_sensor_tsense_state_v(u32 r)
86{
87 return (r >> 29) & 0x3;
88}
89static inline u32 therm_temp_sensor_tsense_state_valid_v(void)
90{
91 return 0x00000001;
92}
93static inline u32 therm_temp_sensor_tsense_state_shadow_v(void)
94{
95 return 0x00000002;
96}
97static inline u32 therm_gate_ctrl_r(u32 i)
98{
99 return 0x00020200 + i*4;
100}
101static inline u32 therm_gate_ctrl_eng_clk_m(void)
102{
103 return 0x3 << 0;
104}
105static inline u32 therm_gate_ctrl_eng_clk_run_f(void)
106{
107 return 0x0;
108}
109static inline u32 therm_gate_ctrl_eng_clk_auto_f(void)
110{
111 return 0x1;
112}
113static inline u32 therm_gate_ctrl_eng_clk_stop_f(void)
114{
115 return 0x2;
116}
117static inline u32 therm_gate_ctrl_blk_clk_m(void)
118{
119 return 0x3 << 2;
120}
121static inline u32 therm_gate_ctrl_blk_clk_run_f(void)
122{
123 return 0x0;
124}
125static inline u32 therm_gate_ctrl_blk_clk_auto_f(void)
126{
127 return 0x4;
128}
129static inline u32 therm_gate_ctrl_eng_idle_filt_exp_f(u32 v)
130{
131 return (v & 0x1f) << 8;
132}
133static inline u32 therm_gate_ctrl_eng_idle_filt_exp_m(void)
134{
135 return 0x1f << 8;
136}
137static inline u32 therm_gate_ctrl_eng_idle_filt_mant_f(u32 v)
138{
139 return (v & 0x7) << 13;
140}
141static inline u32 therm_gate_ctrl_eng_idle_filt_mant_m(void)
142{
143 return 0x7 << 13;
144}
145static inline u32 therm_gate_ctrl_eng_delay_before_f(u32 v)
146{
147 return (v & 0xf) << 16;
148}
149static inline u32 therm_gate_ctrl_eng_delay_before_m(void)
150{
151 return 0xf << 16;
152}
153static inline u32 therm_gate_ctrl_eng_delay_after_f(u32 v)
154{
155 return (v & 0xf) << 20;
156}
157static inline u32 therm_gate_ctrl_eng_delay_after_m(void)
158{
159 return 0xf << 20;
160}
161static inline u32 therm_fecs_idle_filter_r(void)
162{
163 return 0x00020288;
164}
165static inline u32 therm_fecs_idle_filter_value_m(void)
166{
167 return 0xffffffff << 0;
168}
169static inline u32 therm_hubmmu_idle_filter_r(void)
170{
171 return 0x0002028c;
172}
173static inline u32 therm_hubmmu_idle_filter_value_m(void)
174{
175 return 0xffffffff << 0;
176}
177#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_timer_gp106.h b/drivers/gpu/nvgpu/gp106/hw_timer_gp106.h
new file mode 100644
index 00000000..62771628
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_timer_gp106.h
@@ -0,0 +1,109 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_timer_gp106_h_
51#define _hw_timer_gp106_h_
52
53static inline u32 timer_pri_timeout_r(void)
54{
55 return 0x00009080;
56}
57static inline u32 timer_pri_timeout_period_f(u32 v)
58{
59 return (v & 0xffffff) << 0;
60}
61static inline u32 timer_pri_timeout_period_m(void)
62{
63 return 0xffffff << 0;
64}
65static inline u32 timer_pri_timeout_period_v(u32 r)
66{
67 return (r >> 0) & 0xffffff;
68}
69static inline u32 timer_pri_timeout_en_f(u32 v)
70{
71 return (v & 0x1) << 31;
72}
73static inline u32 timer_pri_timeout_en_m(void)
74{
75 return 0x1 << 31;
76}
77static inline u32 timer_pri_timeout_en_v(u32 r)
78{
79 return (r >> 31) & 0x1;
80}
81static inline u32 timer_pri_timeout_en_en_enabled_f(void)
82{
83 return 0x80000000;
84}
85static inline u32 timer_pri_timeout_en_en_disabled_f(void)
86{
87 return 0x0;
88}
89static inline u32 timer_pri_timeout_save_0_r(void)
90{
91 return 0x00009084;
92}
93static inline u32 timer_pri_timeout_save_1_r(void)
94{
95 return 0x00009088;
96}
97static inline u32 timer_pri_timeout_fecs_errcode_r(void)
98{
99 return 0x0000908c;
100}
101static inline u32 timer_time_0_r(void)
102{
103 return 0x00009400;
104}
105static inline u32 timer_time_1_r(void)
106{
107 return 0x00009410;
108}
109#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_top_gp106.h b/drivers/gpu/nvgpu/gp106/hw_top_gp106.h
new file mode 100644
index 00000000..85350954
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_top_gp106.h
@@ -0,0 +1,221 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_top_gp106_h_
51#define _hw_top_gp106_h_
52
53static inline u32 top_num_gpcs_r(void)
54{
55 return 0x00022430;
56}
57static inline u32 top_num_gpcs_value_v(u32 r)
58{
59 return (r >> 0) & 0x1f;
60}
61static inline u32 top_tpc_per_gpc_r(void)
62{
63 return 0x00022434;
64}
65static inline u32 top_tpc_per_gpc_value_v(u32 r)
66{
67 return (r >> 0) & 0x1f;
68}
69static inline u32 top_num_fbps_r(void)
70{
71 return 0x00022438;
72}
73static inline u32 top_num_fbps_value_v(u32 r)
74{
75 return (r >> 0) & 0x1f;
76}
77static inline u32 top_num_fbpas_r(void)
78{
79 return 0x0002243c;
80}
81static inline u32 top_num_fbpas_value_v(u32 r)
82{
83 return (r >> 0) & 0x1f;
84}
85static inline u32 top_ltc_per_fbp_r(void)
86{
87 return 0x00022450;
88}
89static inline u32 top_ltc_per_fbp_value_v(u32 r)
90{
91 return (r >> 0) & 0x1f;
92}
93static inline u32 top_slices_per_ltc_r(void)
94{
95 return 0x0002245c;
96}
97static inline u32 top_slices_per_ltc_value_v(u32 r)
98{
99 return (r >> 0) & 0x1f;
100}
101static inline u32 top_num_ltcs_r(void)
102{
103 return 0x00022454;
104}
105static inline u32 top_device_info_r(u32 i)
106{
107 return 0x00022700 + i*4;
108}
109static inline u32 top_device_info__size_1_v(void)
110{
111 return 0x00000040;
112}
113static inline u32 top_device_info_chain_v(u32 r)
114{
115 return (r >> 31) & 0x1;
116}
117static inline u32 top_device_info_chain_enable_v(void)
118{
119 return 0x00000001;
120}
121static inline u32 top_device_info_engine_enum_v(u32 r)
122{
123 return (r >> 26) & 0xf;
124}
125static inline u32 top_device_info_runlist_enum_v(u32 r)
126{
127 return (r >> 21) & 0xf;
128}
129static inline u32 top_device_info_intr_enum_v(u32 r)
130{
131 return (r >> 15) & 0x1f;
132}
133static inline u32 top_device_info_reset_enum_v(u32 r)
134{
135 return (r >> 9) & 0x1f;
136}
137static inline u32 top_device_info_type_enum_v(u32 r)
138{
139 return (r >> 2) & 0x1fffffff;
140}
141static inline u32 top_device_info_type_enum_graphics_v(void)
142{
143 return 0x00000000;
144}
145static inline u32 top_device_info_type_enum_graphics_f(void)
146{
147 return 0x0;
148}
149static inline u32 top_device_info_type_enum_copy0_v(void)
150{
151 return 0x00000001;
152}
153static inline u32 top_device_info_type_enum_copy0_f(void)
154{
155 return 0x4;
156}
157static inline u32 top_device_info_type_enum_lce_v(void)
158{
159 return 0x00000013;
160}
161static inline u32 top_device_info_type_enum_lce_f(void)
162{
163 return 0x4c;
164}
165static inline u32 top_device_info_entry_v(u32 r)
166{
167 return (r >> 0) & 0x3;
168}
169static inline u32 top_device_info_entry_not_valid_v(void)
170{
171 return 0x00000000;
172}
173static inline u32 top_device_info_entry_enum_v(void)
174{
175 return 0x00000002;
176}
177static inline u32 top_device_info_entry_data_v(void)
178{
179 return 0x00000001;
180}
181static inline u32 top_device_info_data_type_v(u32 r)
182{
183 return (r >> 30) & 0x1;
184}
185static inline u32 top_device_info_data_type_enum2_v(void)
186{
187 return 0x00000000;
188}
189static inline u32 top_device_info_data_inst_id_v(u32 r)
190{
191 return (r >> 26) & 0xf;
192}
193static inline u32 top_device_info_data_pri_base_v(u32 r)
194{
195 return (r >> 12) & 0xfff;
196}
197static inline u32 top_device_info_data_pri_base_align_v(void)
198{
199 return 0x0000000c;
200}
201static inline u32 top_device_info_data_fault_id_enum_v(u32 r)
202{
203 return (r >> 3) & 0x1f;
204}
205static inline u32 top_device_info_data_fault_id_v(u32 r)
206{
207 return (r >> 2) & 0x1;
208}
209static inline u32 top_device_info_data_fault_id_valid_v(void)
210{
211 return 0x00000001;
212}
213static inline u32 top_scratch1_r(void)
214{
215 return 0x0002240c;
216}
217static inline u32 top_scratch1_devinit_completed_v(u32 r)
218{
219 return (r >> 1) & 0x1;
220}
221#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_trim_gp106.h b/drivers/gpu/nvgpu/gp106/hw_trim_gp106.h
new file mode 100644
index 00000000..42d3fd32
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_trim_gp106.h
@@ -0,0 +1,189 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_trim_gp106_h_
51#define _hw_trim_gp106_h_
52static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_r(void)
53{
54 return 0x00132924;
55}
56static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_noofipclks_s(void)
57{
58 return 16;
59}
60static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_noofipclks_f(u32 v)
61{
62 return (v & 0xffff) << 0;
63}
64static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_noofipclks_m(void)
65{
66 return 0xffff << 0;
67}
68static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_noofipclks_v(u32 r)
69{
70 return (r >> 0) & 0xffff;
71}
72static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_write_en_s(void)
73{
74 return 1;
75}
76static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_write_en_f(u32 v)
77{
78 return (v & 0x1) << 16;
79}
80static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_write_en_m(void)
81{
82 return 0x1 << 16;
83}
84static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_write_en_v(u32 r)
85{
86 return (r >> 16) & 0x1;
87}
88static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_write_en_deasserted_f(void)
89{
90 return 0;
91}
92static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_write_en_asserted_f(void)
93{
94 return 0x10000;
95}
96static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_enable_s(void)
97{
98 return 1;
99}
100static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_enable_f(u32 v)
101{
102 return (v & 0x1) << 20;
103}
104static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_enable_m(void)
105{
106 return 0x1 << 20;
107}
108static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_enable_v(u32 r)
109{
110 return (r >> 20) & 0x1;
111}
112static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_enable_deasserted_f(void)
113{
114 return 0;
115}
116static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_enable_asserted_f(void)
117{
118 return 0x100000;
119}
120static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_reset_s(void)
121{
122 return 1;
123}
124static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_reset_f(u32 v)
125{
126 return (v & 0x1) << 24;
127}
128static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_reset_m(void)
129{
130 return 0x1 << 24;
131}
132static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_reset_v(u32 r)
133{
134 return (r >> 24) & 0x1;
135}
136static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_reset_deasserted_f(void)
137{
138 return 0;
139}
140static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_reset_asserted_f(void)
141{
142 return 0x1000000;
143}
144static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cfg_source_gpc2clk_f(void)
145{
146 return 0x70000000;
147}
148static inline u32 trim_gpc_bcast_clk_cntr_ncgpcclk_cnt_r(void)
149{
150 return 0x00132928;
151}
152static inline u32 trim_fbpa_bcast_clk_cntr_ncltcclk_cfg_r(void)
153{
154 return 0x00132128;
155}
156static inline u32 trim_fbpa_bcast_clk_cntr_ncltcclk_cfg_source_dramdiv4_rec_clk1_f(void)
157{
158 return 0x20000000;
159}
160static inline u32 trim_fbpa_bcast_clk_cntr_ncltcclk_cnt_r(void)
161{
162 return 0x0013212c;
163}
164static inline u32 trim_sys_clk_cntr_ncltcpll_cfg_r(void)
165{
166 return 0x001373c0;
167}
168static inline u32 trim_sys_clk_cntr_ncltcpll_cfg_source_xbar2clk_f(void)
169{
170 return 0x20000000;
171}
172static inline u32 trim_sys_clk_cntr_ncltcpll_cnt_r(void)
173{
174 return 0x001373c4;
175}
176static inline u32 trim_sys_clk_cntr_ncsyspll_cfg_r(void)
177{
178 return 0x001373b0;
179}
180static inline u32 trim_sys_clk_cntr_ncsyspll_cfg_source_sys2clk_f(void)
181{
182 return 0x0;
183}
184static inline u32 trim_sys_clk_cntr_ncsyspll_cnt_r(void)
185{
186 return 0x001373b4;
187}
188
189#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_xp_gp106.h b/drivers/gpu/nvgpu/gp106/hw_xp_gp106.h
new file mode 100644
index 00000000..40b14da1
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_xp_gp106.h
@@ -0,0 +1,137 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_xp_gp106_h_
51#define _hw_xp_gp106_h_
52
53static inline u32 xp_dl_mgr_r(u32 i)
54{
55 return 0x0008b8c0 + i*4;
56}
57static inline u32 xp_dl_mgr_safe_timing_f(u32 v)
58{
59 return (v & 0x1) << 2;
60}
61static inline u32 xp_pl_link_config_r(u32 i)
62{
63 return 0x0008c040 + i*4;
64}
65static inline u32 xp_pl_link_config_ltssm_status_f(u32 v)
66{
67 return (v & 0x1) << 4;
68}
69static inline u32 xp_pl_link_config_ltssm_status_idle_v(void)
70{
71 return 0x00000000;
72}
73static inline u32 xp_pl_link_config_ltssm_directive_f(u32 v)
74{
75 return (v & 0xf) << 0;
76}
77static inline u32 xp_pl_link_config_ltssm_directive_m(void)
78{
79 return 0xf << 0;
80}
81static inline u32 xp_pl_link_config_ltssm_directive_normal_operations_v(void)
82{
83 return 0x00000000;
84}
85static inline u32 xp_pl_link_config_ltssm_directive_change_speed_v(void)
86{
87 return 0x00000001;
88}
89static inline u32 xp_pl_link_config_max_link_rate_f(u32 v)
90{
91 return (v & 0x3) << 18;
92}
93static inline u32 xp_pl_link_config_max_link_rate_m(void)
94{
95 return 0x3 << 18;
96}
97static inline u32 xp_pl_link_config_max_link_rate_2500_mtps_v(void)
98{
99 return 0x00000002;
100}
101static inline u32 xp_pl_link_config_max_link_rate_5000_mtps_v(void)
102{
103 return 0x00000001;
104}
105static inline u32 xp_pl_link_config_max_link_rate_8000_mtps_v(void)
106{
107 return 0x00000000;
108}
109static inline u32 xp_pl_link_config_target_tx_width_f(u32 v)
110{
111 return (v & 0x7) << 20;
112}
113static inline u32 xp_pl_link_config_target_tx_width_m(void)
114{
115 return 0x7 << 20;
116}
117static inline u32 xp_pl_link_config_target_tx_width_x1_v(void)
118{
119 return 0x00000007;
120}
121static inline u32 xp_pl_link_config_target_tx_width_x2_v(void)
122{
123 return 0x00000006;
124}
125static inline u32 xp_pl_link_config_target_tx_width_x4_v(void)
126{
127 return 0x00000005;
128}
129static inline u32 xp_pl_link_config_target_tx_width_x8_v(void)
130{
131 return 0x00000004;
132}
133static inline u32 xp_pl_link_config_target_tx_width_x16_v(void)
134{
135 return 0x00000000;
136}
137#endif
diff --git a/drivers/gpu/nvgpu/gp106/hw_xve_gp106.h b/drivers/gpu/nvgpu/gp106/hw_xve_gp106.h
new file mode 100644
index 00000000..24434ae0
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/hw_xve_gp106.h
@@ -0,0 +1,149 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_xve_gp106_h_
51#define _hw_xve_gp106_h_
52
53static inline u32 xve_rom_ctrl_r(void)
54{
55 return 0x00000050;
56}
57static inline u32 xve_rom_ctrl_rom_shadow_f(u32 v)
58{
59 return (v & 0x1) << 0;
60}
61static inline u32 xve_rom_ctrl_rom_shadow_disabled_f(void)
62{
63 return 0x0;
64}
65static inline u32 xve_rom_ctrl_rom_shadow_enabled_f(void)
66{
67 return 0x1;
68}
69static inline u32 xve_link_control_status_r(void)
70{
71 return 0x00000088;
72}
73static inline u32 xve_link_control_status_link_speed_m(void)
74{
75 return 0xf << 16;
76}
77static inline u32 xve_link_control_status_link_speed_v(u32 r)
78{
79 return (r >> 16) & 0xf;
80}
81static inline u32 xve_link_control_status_link_speed_link_speed_2p5_v(void)
82{
83 return 0x00000001;
84}
85static inline u32 xve_link_control_status_link_speed_link_speed_5p0_v(void)
86{
87 return 0x00000002;
88}
89static inline u32 xve_link_control_status_link_speed_link_speed_8p0_v(void)
90{
91 return 0x00000003;
92}
93static inline u32 xve_link_control_status_link_width_m(void)
94{
95 return 0x3f << 20;
96}
97static inline u32 xve_link_control_status_link_width_v(u32 r)
98{
99 return (r >> 20) & 0x3f;
100}
101static inline u32 xve_link_control_status_link_width_x1_v(void)
102{
103 return 0x00000001;
104}
105static inline u32 xve_link_control_status_link_width_x2_v(void)
106{
107 return 0x00000002;
108}
109static inline u32 xve_link_control_status_link_width_x4_v(void)
110{
111 return 0x00000004;
112}
113static inline u32 xve_link_control_status_link_width_x8_v(void)
114{
115 return 0x00000008;
116}
117static inline u32 xve_link_control_status_link_width_x16_v(void)
118{
119 return 0x00000010;
120}
121static inline u32 xve_priv_xv_r(void)
122{
123 return 0x00000150;
124}
125static inline u32 xve_priv_xv_cya_l0s_enable_f(u32 v)
126{
127 return (v & 0x1) << 7;
128}
129static inline u32 xve_priv_xv_cya_l0s_enable_m(void)
130{
131 return 0x1 << 7;
132}
133static inline u32 xve_priv_xv_cya_l0s_enable_v(u32 r)
134{
135 return (r >> 7) & 0x1;
136}
137static inline u32 xve_priv_xv_cya_l1_enable_f(u32 v)
138{
139 return (v & 0x1) << 8;
140}
141static inline u32 xve_priv_xv_cya_l1_enable_m(void)
142{
143 return 0x1 << 8;
144}
145static inline u32 xve_priv_xv_cya_l1_enable_v(u32 r)
146{
147 return (r >> 8) & 0x1;
148}
149#endif
diff --git a/drivers/gpu/nvgpu/gp106/ltc_gp106.c b/drivers/gpu/nvgpu/gp106/ltc_gp106.c
new file mode 100644
index 00000000..b162ddb3
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/ltc_gp106.c
@@ -0,0 +1,29 @@
1/*
2 * Copyright (c) 2016, 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
14#include <linux/types.h>
15
16#include "gk20a/gk20a.h"
17#include "gm20b/ltc_gm20b.h"
18#include "gp10b/ltc_gp10b.h"
19#include "gp106/ltc_gp106.h"
20
21void gp106_init_ltc(struct gpu_ops *gops)
22{
23 gp10b_init_ltc(gops);
24
25 /* dGPU does not need the LTC hack */
26 gops->ltc.cbc_fix_config = NULL;
27 gops->ltc.init_cbc = NULL;
28 gops->ltc.init_fs_state = gm20b_ltc_init_fs_state;
29}
diff --git a/drivers/gpu/nvgpu/gp106/ltc_gp106.h b/drivers/gpu/nvgpu/gp106/ltc_gp106.h
new file mode 100644
index 00000000..4720d7a1
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/ltc_gp106.h
@@ -0,0 +1,19 @@
1/*
2 * Copyright (c) 2016, 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
14#ifndef LTC_GP106_H
15#define LTC_GP106_H
16struct gpu_ops;
17
18void gp106_init_ltc(struct gpu_ops *gops);
19#endif
diff --git a/drivers/gpu/nvgpu/gp106/mm_gp106.c b/drivers/gpu/nvgpu/gp106/mm_gp106.c
new file mode 100644
index 00000000..3309a0d7
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/mm_gp106.c
@@ -0,0 +1,41 @@
1/*
2 * GP106 memory management
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include "gk20a/gk20a.h"
17#include "gp10b/mm_gp10b.h"
18#include "gp106/mm_gp106.h"
19
20#include "hw_fb_gp106.h"
21
22static size_t gp106_mm_get_vidmem_size(struct gk20a *g)
23{
24 u32 range = gk20a_readl(g, fb_mmu_local_memory_range_r());
25 u32 mag = fb_mmu_local_memory_range_lower_mag_v(range);
26 u32 scale = fb_mmu_local_memory_range_lower_scale_v(range);
27 u32 ecc = fb_mmu_local_memory_range_ecc_mode_v(range);
28 size_t bytes = ((size_t)mag << scale) * SZ_1M;
29
30 if (ecc)
31 bytes = bytes / 16 * 15;
32
33 return bytes;
34}
35
36void gp106_init_mm(struct gpu_ops *gops)
37{
38 gp10b_init_mm(gops);
39 gops->mm.get_vidmem_size = gp106_mm_get_vidmem_size;
40 gops->mm.get_physical_addr_bits = NULL;
41}
diff --git a/drivers/gpu/nvgpu/gp106/mm_gp106.h b/drivers/gpu/nvgpu/gp106/mm_gp106.h
new file mode 100644
index 00000000..36a89a11
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/mm_gp106.h
@@ -0,0 +1,23 @@
1/*
2 * GP106 memory management
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef MM_GP106_H
17#define MM_GP106_H
18
19struct gpu_ops;
20
21void gp106_init_mm(struct gpu_ops *gops);
22
23#endif
diff --git a/drivers/gpu/nvgpu/gp106/pmu_gp106.c b/drivers/gpu/nvgpu/gp106/pmu_gp106.c
new file mode 100644
index 00000000..eecd7351
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/pmu_gp106.c
@@ -0,0 +1,296 @@
1/*
2 * Copyright (c) 2016, 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
14#include <linux/delay.h> /* for udelay */
15#include "gk20a/gk20a.h"
16#include "gk20a/pmu_gk20a.h"
17
18#include "gm206/pmu_gm206.h"
19#include "gm20b/pmu_gm20b.h"
20#include "gp10b/pmu_gp10b.h"
21#include "gp106/pmu_gp106.h"
22#include "gp106/acr_gp106.h"
23#include "gp106/hw_psec_gp106.h"
24#include "clk/clk_mclk.h"
25#include "hw_mc_gp106.h"
26#include "hw_pwr_gp106.h"
27#include "lpwr/lpwr.h"
28#include "lpwr/rppg.h"
29
30#define PMU_MEM_SCRUBBING_TIMEOUT_MAX 1000
31#define PMU_MEM_SCRUBBING_TIMEOUT_DEFAULT 10
32
33static int gp106_pmu_enable_hw(struct pmu_gk20a *pmu, bool enable)
34{
35 struct gk20a *g = gk20a_from_pmu(pmu);
36
37 gk20a_dbg_fn("");
38
39 /*
40 * From GP10X onwards, we are using PPWR_FALCON_ENGINE for reset. And as
41 * it may come into same behaviour, reading NV_PPWR_FALCON_ENGINE again
42 * after Reset.
43 */
44
45 if (enable) {
46 int retries = PMU_MEM_SCRUBBING_TIMEOUT_MAX /
47 PMU_MEM_SCRUBBING_TIMEOUT_DEFAULT;
48 gk20a_writel(g, pwr_falcon_engine_r(),
49 pwr_falcon_engine_reset_false_f());
50 gk20a_readl(g, pwr_falcon_engine_r());
51
52 /* make sure ELPG is in a good state */
53 if (g->ops.clock_gating.slcg_pmu_load_gating_prod)
54 g->ops.clock_gating.slcg_pmu_load_gating_prod(g,
55 g->slcg_enabled);
56 if (g->ops.clock_gating.blcg_pmu_load_gating_prod)
57 g->ops.clock_gating.blcg_pmu_load_gating_prod(g,
58 g->blcg_enabled);
59
60 /* wait for Scrubbing to complete */
61 do {
62 u32 w = gk20a_readl(g, pwr_falcon_dmactl_r()) &
63 (pwr_falcon_dmactl_dmem_scrubbing_m() |
64 pwr_falcon_dmactl_imem_scrubbing_m());
65
66 if (!w) {
67 gk20a_dbg_fn("done");
68 return 0;
69 }
70 udelay(PMU_MEM_SCRUBBING_TIMEOUT_DEFAULT);
71 } while (--retries || !tegra_platform_is_silicon());
72
73 /* If scrubbing timeout, keep PMU in reset state */
74 gk20a_writel(g, pwr_falcon_engine_r(),
75 pwr_falcon_engine_reset_true_f());
76 gk20a_readl(g, pwr_falcon_engine_r());
77 gk20a_err(dev_from_gk20a(g), "Falcon mem scrubbing timeout");
78 return -ETIMEDOUT;
79 } else {
80 /* DISBALE */
81 gk20a_writel(g, pwr_falcon_engine_r(),
82 pwr_falcon_engine_reset_true_f());
83 gk20a_readl(g, pwr_falcon_engine_r());
84 return 0;
85 }
86}
87
88static int pmu_enable(struct pmu_gk20a *pmu, bool enable)
89{
90 struct gk20a *g = gk20a_from_pmu(pmu);
91 u32 reg_reset;
92 int err;
93
94 gk20a_dbg_fn("");
95
96 if (!enable) {
97 reg_reset = gk20a_readl(g, pwr_falcon_engine_r());
98 if (reg_reset !=
99 pwr_falcon_engine_reset_true_f()) {
100
101 pmu_enable_irq(pmu, false);
102 gp106_pmu_enable_hw(pmu, false);
103 udelay(10);
104 }
105 } else {
106 gp106_pmu_enable_hw(pmu, true);
107 /* TBD: post reset */
108
109 /*idle the PMU and enable interrupts on the Falcon*/
110 err = pmu_idle(pmu);
111 if (err)
112 return err;
113 udelay(5);
114 pmu_enable_irq(pmu, true);
115 }
116
117 gk20a_dbg_fn("done");
118 return 0;
119}
120
121static int gp106_pmu_reset(struct gk20a *g)
122{
123 struct pmu_gk20a *pmu = &g->pmu;
124 int err = 0;
125
126 gk20a_dbg_fn("");
127
128 err = pmu_idle(pmu);
129 if (err)
130 return err;
131
132 /* TBD: release pmu hw mutex */
133
134 err = pmu_enable(pmu, false);
135 if (err)
136 return err;
137
138 /* TBD: cancel all sequences */
139 /* TBD: init all sequences and state tables */
140 /* TBD: restore pre-init message handler */
141
142 err = pmu_enable(pmu, true);
143 if (err)
144 return err;
145
146 return err;
147}
148
149static int gp106_sec2_reset(struct gk20a *g)
150{
151 gk20a_dbg_fn("");
152 //sec2 reset
153 gk20a_writel(g, psec_falcon_engine_r(),
154 pwr_falcon_engine_reset_true_f());
155 udelay(10);
156 gk20a_writel(g, psec_falcon_engine_r(),
157 pwr_falcon_engine_reset_false_f());
158
159 gk20a_dbg_fn("done");
160 return 0;
161}
162
163static int gp106_falcon_reset(struct gk20a *g)
164{
165 gk20a_dbg_fn("");
166
167 gp106_pmu_reset(g);
168 gp106_sec2_reset(g);
169
170 gk20a_dbg_fn("done");
171 return 0;
172}
173
174static bool gp106_is_pmu_supported(struct gk20a *g)
175{
176 return true;
177}
178
179static u32 gp106_pmu_pg_feature_list(struct gk20a *g, u32 pg_engine_id)
180{
181 if (pg_engine_id == PMU_PG_ELPG_ENGINE_ID_GRAPHICS)
182 return PMU_PG_FEATURE_GR_RPPG_ENABLED;
183
184 if (pg_engine_id == PMU_PG_ELPG_ENGINE_ID_MS)
185 return NVGPU_PMU_MS_FEATURE_MASK_ALL;
186
187 return 0;
188}
189
190static u32 gp106_pmu_pg_engines_list(struct gk20a *g)
191{
192 return BIT(PMU_PG_ELPG_ENGINE_ID_GRAPHICS) |
193 BIT(PMU_PG_ELPG_ENGINE_ID_MS);
194}
195
196static void pmu_handle_param_msg(struct gk20a *g, struct pmu_msg *msg,
197 void *param, u32 handle, u32 status)
198{
199 gk20a_dbg_fn("");
200
201 if (status != 0) {
202 gk20a_err(dev_from_gk20a(g), "PG PARAM cmd aborted");
203 return;
204 }
205
206 gp106_dbg_pmu("PG PARAM is acknowledged from PMU %x",
207 msg->msg.pg.msg_type);
208}
209
210static int gp106_pg_param_init(struct gk20a *g, u32 pg_engine_id)
211{
212 struct pmu_gk20a *pmu = &g->pmu;
213 struct pmu_cmd cmd;
214 u32 seq;
215 u32 status;
216
217 memset(&cmd, 0, sizeof(struct pmu_cmd));
218 if (pg_engine_id == PMU_PG_ELPG_ENGINE_ID_GRAPHICS) {
219
220 status = init_rppg(g);
221 if (status != 0) {
222 gk20a_err(dev_from_gk20a(g), "RPPG init Failed");
223 return -1;
224 }
225
226 cmd.hdr.unit_id = PMU_UNIT_PG;
227 cmd.hdr.size = PMU_CMD_HDR_SIZE +
228 sizeof(struct pmu_pg_cmd_gr_init_param);
229 cmd.cmd.pg.gr_init_param.cmd_type =
230 PMU_PG_CMD_ID_PG_PARAM;
231 cmd.cmd.pg.gr_init_param.sub_cmd_id =
232 PMU_PG_PARAM_CMD_GR_INIT_PARAM;
233 cmd.cmd.pg.gr_init_param.featuremask =
234 PMU_PG_FEATURE_GR_RPPG_ENABLED;
235
236 gp106_dbg_pmu("cmd post GR PMU_PG_CMD_ID_PG_PARAM");
237 gk20a_pmu_cmd_post(g, &cmd, NULL, NULL, PMU_COMMAND_QUEUE_HPQ,
238 pmu_handle_param_msg, pmu, &seq, ~0);
239 } else if (pg_engine_id == PMU_PG_ELPG_ENGINE_ID_MS) {
240 cmd.hdr.unit_id = PMU_UNIT_PG;
241 cmd.hdr.size = PMU_CMD_HDR_SIZE +
242 sizeof(struct pmu_pg_cmd_ms_init_param);
243 cmd.cmd.pg.ms_init_param.cmd_type =
244 PMU_PG_CMD_ID_PG_PARAM;
245 cmd.cmd.pg.ms_init_param.cmd_id =
246 PMU_PG_PARAM_CMD_MS_INIT_PARAM;
247 cmd.cmd.pg.ms_init_param.support_mask =
248 NVGPU_PMU_MS_FEATURE_MASK_CLOCK_GATING |
249 NVGPU_PMU_MS_FEATURE_MASK_SW_ASR |
250 NVGPU_PMU_MS_FEATURE_MASK_RPPG |
251 NVGPU_PMU_MS_FEATURE_MASK_FB_TRAINING;
252
253 gp106_dbg_pmu("cmd post MS PMU_PG_CMD_ID_PG_PARAM");
254 gk20a_pmu_cmd_post(g, &cmd, NULL, NULL, PMU_COMMAND_QUEUE_HPQ,
255 pmu_handle_param_msg, pmu, &seq, ~0);
256 }
257
258 return 0;
259}
260
261void gp106_init_pmu_ops(struct gpu_ops *gops)
262{
263 gk20a_dbg_fn("");
264
265 if (gops->privsecurity) {
266 gp106_init_secure_pmu(gops);
267 gops->pmu.init_wpr_region = gm20b_pmu_init_acr;
268 gops->pmu.load_lsfalcon_ucode = gm206_load_falcon_ucode;
269 gops->pmu.is_lazy_bootstrap = gm206_is_lazy_bootstrap;
270 gops->pmu.is_priv_load = gm206_is_priv_load;
271 } else {
272 gk20a_init_pmu_ops(gops);
273 gops->pmu.pmu_setup_hw_and_bootstrap =
274 gm20b_init_nspmu_setup_hw1;
275 gops->pmu.load_lsfalcon_ucode = NULL;
276 gops->pmu.init_wpr_region = NULL;
277 }
278 gops->pmu.pmu_setup_elpg = NULL;
279 gops->pmu.lspmuwprinitdone = 0;
280 gops->pmu.fecsbootstrapdone = false;
281 gops->pmu.write_dmatrfbase = gp10b_write_dmatrfbase;
282 gops->pmu.pmu_elpg_statistics = gp10b_pmu_elpg_statistics;
283 gops->pmu.pmu_pg_init_param = gp106_pg_param_init;
284 gops->pmu.pmu_pg_supported_engines_list = gp106_pmu_pg_engines_list;
285 gops->pmu.pmu_pg_engines_feature_list = gp106_pmu_pg_feature_list;
286 gops->pmu.pmu_lpwr_enable_pg = nvgpu_lpwr_enable_pg;
287 gops->pmu.pmu_lpwr_disable_pg = nvgpu_lpwr_disable_pg;
288 gops->pmu.pmu_pg_param_post_init = nvgpu_lpwr_post_init;
289 gops->pmu.send_lrf_tex_ltc_dram_overide_en_dis_cmd = NULL;
290 gops->pmu.dump_secure_fuses = NULL;
291 gops->pmu.reset = gp106_falcon_reset;
292 gops->pmu.mclk_init = clk_mclkseq_init_mclk_gddr5;
293 gops->pmu.is_pmu_supported = gp106_is_pmu_supported;
294
295 gk20a_dbg_fn("done");
296}
diff --git a/drivers/gpu/nvgpu/gp106/pmu_gp106.h b/drivers/gpu/nvgpu/gp106/pmu_gp106.h
new file mode 100644
index 00000000..a42ff620
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/pmu_gp106.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (c) 2016, 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
14#ifndef __PMU_GP106_H_
15#define __PMU_GP106_H_
16
17#define gp106_dbg_pmu(fmt, arg...) \
18 gk20a_dbg(gpu_dbg_pmu, fmt, ##arg)
19
20void gp106_init_pmu_ops(struct gpu_ops *gops);
21
22#endif /*__PMU_GP106_H_*/
diff --git a/drivers/gpu/nvgpu/gp106/regops_gp106.c b/drivers/gpu/nvgpu/gp106/regops_gp106.c
new file mode 100644
index 00000000..5b6897c1
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/regops_gp106.c
@@ -0,0 +1,1815 @@
1/*
2 * Tegra GP106 GPU Debugger Driver Register Ops
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/slab.h>
20#include <linux/err.h>
21#include <linux/bsearch.h>
22#include <uapi/linux/nvgpu.h>
23
24#include "gk20a/gk20a.h"
25#include "gk20a/dbg_gpu_gk20a.h"
26#include "gk20a/regops_gk20a.h"
27#include "regops_gp106.h"
28
29static const struct regop_offset_range gp106_global_whitelist_ranges[] = {
30 { 0x000004f0, 1},
31 { 0x00001a00, 3},
32 { 0x00002800, 128},
33 { 0x00009400, 1},
34 { 0x00009410, 1},
35 { 0x00009480, 1},
36 { 0x00020200, 24},
37 { 0x00021c04, 3},
38 { 0x00021c14, 3},
39 { 0x00021c24, 71},
40 { 0x00021d44, 1},
41 { 0x00021d4c, 1},
42 { 0x00021d54, 1},
43 { 0x00021d5c, 1},
44 { 0x00021d68, 19},
45 { 0x00021dbc, 16},
46 { 0x00022430, 7},
47 { 0x00022450, 1},
48 { 0x0002245c, 2},
49 { 0x00070000, 5},
50 { 0x000840a8, 1},
51 { 0x00084b5c, 1},
52 { 0x000870a8, 1},
53 { 0x000884e0, 1},
54 { 0x000884f4, 1},
55 { 0x0008e00c, 1},
56 { 0x00100c18, 3},
57 { 0x00100c84, 1},
58 { 0x0010a0a8, 1},
59 { 0x0010a4f0, 1},
60 { 0x0013c808, 2},
61 { 0x0013cc14, 1},
62 { 0x0013cc34, 1},
63 { 0x0013cc54, 1},
64 { 0x0013cc74, 1},
65 { 0x0013cc94, 1},
66 { 0x0013ccb4, 1},
67 { 0x0013ec18, 1},
68 { 0x00140028, 1},
69 { 0x00140280, 1},
70 { 0x001402a0, 1},
71 { 0x00140350, 1},
72 { 0x00140480, 1},
73 { 0x001404a0, 1},
74 { 0x00140550, 1},
75 { 0x00140680, 1},
76 { 0x001406a0, 1},
77 { 0x00140750, 1},
78 { 0x00142028, 1},
79 { 0x00142280, 1},
80 { 0x001422a0, 1},
81 { 0x00142350, 1},
82 { 0x00142480, 1},
83 { 0x001424a0, 1},
84 { 0x00142550, 1},
85 { 0x00142680, 1},
86 { 0x001426a0, 1},
87 { 0x00142750, 1},
88 { 0x00144028, 1},
89 { 0x00144280, 1},
90 { 0x00144350, 1},
91 { 0x00144480, 1},
92 { 0x00144550, 1},
93 { 0x00144680, 1},
94 { 0x00144750, 1},
95 { 0x00146028, 1},
96 { 0x00146280, 1},
97 { 0x00146350, 1},
98 { 0x00146480, 1},
99 { 0x00146550, 1},
100 { 0x00146680, 1},
101 { 0x00146750, 1},
102 { 0x00148028, 1},
103 { 0x00148280, 1},
104 { 0x00148350, 1},
105 { 0x00148480, 1},
106 { 0x00148550, 1},
107 { 0x00148680, 1},
108 { 0x00148750, 1},
109 { 0x0014a028, 1},
110 { 0x0014a280, 1},
111 { 0x0014a350, 1},
112 { 0x0014a480, 1},
113 { 0x0014a550, 1},
114 { 0x0014a680, 1},
115 { 0x0014a750, 1},
116 { 0x0014c028, 1},
117 { 0x0014c280, 1},
118 { 0x0014c350, 1},
119 { 0x0014c480, 1},
120 { 0x0014c550, 1},
121 { 0x0014c680, 1},
122 { 0x0014c750, 1},
123 { 0x0014e028, 1},
124 { 0x0014e280, 1},
125 { 0x0014e350, 1},
126 { 0x0014e480, 1},
127 { 0x0014e550, 1},
128 { 0x0014e680, 1},
129 { 0x0014e750, 1},
130 { 0x00150028, 1},
131 { 0x00150280, 1},
132 { 0x00150350, 1},
133 { 0x00150480, 1},
134 { 0x00150550, 1},
135 { 0x00150680, 1},
136 { 0x00150750, 1},
137 { 0x00152028, 1},
138 { 0x00152280, 1},
139 { 0x00152350, 1},
140 { 0x00152480, 1},
141 { 0x00152550, 1},
142 { 0x00152680, 1},
143 { 0x00152750, 1},
144 { 0x00154028, 1},
145 { 0x00154280, 1},
146 { 0x00154350, 1},
147 { 0x00154480, 1},
148 { 0x00154550, 1},
149 { 0x00154680, 1},
150 { 0x00154750, 1},
151 { 0x00156028, 1},
152 { 0x00156280, 1},
153 { 0x00156350, 1},
154 { 0x00156480, 1},
155 { 0x00156550, 1},
156 { 0x00156680, 1},
157 { 0x00156750, 1},
158 { 0x0017e028, 1},
159 { 0x0017e280, 1},
160 { 0x0017e294, 1},
161 { 0x0017e29c, 2},
162 { 0x0017e2ac, 1},
163 { 0x0017e350, 1},
164 { 0x0017e39c, 1},
165 { 0x0017e480, 1},
166 { 0x0017e4a0, 1},
167 { 0x0017e550, 1},
168 { 0x0017e680, 1},
169 { 0x0017e6a0, 1},
170 { 0x0017e750, 1},
171 { 0x00180040, 41},
172 { 0x001800ec, 1},
173 { 0x001800f8, 7},
174 { 0x00180240, 41},
175 { 0x001802ec, 1},
176 { 0x001802f8, 7},
177 { 0x00180440, 41},
178 { 0x001804ec, 1},
179 { 0x001804f8, 7},
180 { 0x00180640, 41},
181 { 0x001806ec, 1},
182 { 0x001806f8, 7},
183 { 0x00180840, 41},
184 { 0x001808ec, 1},
185 { 0x001808f8, 7},
186 { 0x00180a40, 41},
187 { 0x00180aec, 1},
188 { 0x00180af8, 7},
189 { 0x00180c40, 41},
190 { 0x00180cec, 1},
191 { 0x00180cf8, 7},
192 { 0x00180e40, 41},
193 { 0x00180eec, 1},
194 { 0x00180ef8, 7},
195 { 0x00181040, 41},
196 { 0x001810ec, 1},
197 { 0x001810f8, 7},
198 { 0x00181240, 41},
199 { 0x001812ec, 1},
200 { 0x001812f8, 7},
201 { 0x00181440, 41},
202 { 0x001814ec, 1},
203 { 0x001814f8, 7},
204 { 0x00181640, 41},
205 { 0x001816ec, 1},
206 { 0x001816f8, 7},
207 { 0x00181840, 41},
208 { 0x001818ec, 1},
209 { 0x001818f8, 7},
210 { 0x00181a40, 41},
211 { 0x00181aec, 1},
212 { 0x00181af8, 7},
213 { 0x00181c40, 41},
214 { 0x00181cec, 1},
215 { 0x00181cf8, 7},
216 { 0x00181e40, 41},
217 { 0x00181eec, 1},
218 { 0x00181ef8, 7},
219 { 0x00182040, 41},
220 { 0x001820ec, 1},
221 { 0x001820f8, 7},
222 { 0x00182240, 41},
223 { 0x001822ec, 1},
224 { 0x001822f8, 7},
225 { 0x00182440, 41},
226 { 0x001824ec, 1},
227 { 0x001824f8, 7},
228 { 0x00182640, 41},
229 { 0x001826ec, 1},
230 { 0x001826f8, 7},
231 { 0x00182840, 41},
232 { 0x001828ec, 1},
233 { 0x001828f8, 7},
234 { 0x00182a40, 41},
235 { 0x00182aec, 1},
236 { 0x00182af8, 7},
237 { 0x00182c40, 41},
238 { 0x00182cec, 1},
239 { 0x00182cf8, 7},
240 { 0x00182e40, 41},
241 { 0x00182eec, 1},
242 { 0x00182ef8, 7},
243 { 0x00183040, 41},
244 { 0x001830ec, 1},
245 { 0x001830f8, 7},
246 { 0x00183240, 41},
247 { 0x001832ec, 1},
248 { 0x001832f8, 7},
249 { 0x00183440, 41},
250 { 0x001834ec, 1},
251 { 0x001834f8, 7},
252 { 0x00183640, 41},
253 { 0x001836ec, 1},
254 { 0x001836f8, 7},
255 { 0x00183840, 41},
256 { 0x001838ec, 1},
257 { 0x001838f8, 7},
258 { 0x00183a40, 41},
259 { 0x00183aec, 1},
260 { 0x00183af8, 7},
261 { 0x00183c40, 41},
262 { 0x00183cec, 1},
263 { 0x00183cf8, 7},
264 { 0x00183e40, 41},
265 { 0x00183eec, 1},
266 { 0x00183ef8, 7},
267 { 0x00184040, 41},
268 { 0x001840ec, 1},
269 { 0x001840f8, 7},
270 { 0x00184240, 41},
271 { 0x001842ec, 1},
272 { 0x001842f8, 7},
273 { 0x00184440, 41},
274 { 0x001844ec, 1},
275 { 0x001844f8, 7},
276 { 0x00184640, 41},
277 { 0x001846ec, 1},
278 { 0x001846f8, 7},
279 { 0x00184840, 41},
280 { 0x001848ec, 1},
281 { 0x001848f8, 7},
282 { 0x00184a40, 41},
283 { 0x00184aec, 1},
284 { 0x00184af8, 7},
285 { 0x00184c40, 41},
286 { 0x00184cec, 1},
287 { 0x00184cf8, 7},
288 { 0x00184e40, 41},
289 { 0x00184eec, 1},
290 { 0x00184ef8, 7},
291 { 0x00185040, 41},
292 { 0x001850ec, 1},
293 { 0x001850f8, 7},
294 { 0x00185240, 41},
295 { 0x001852ec, 1},
296 { 0x001852f8, 7},
297 { 0x00185440, 41},
298 { 0x001854ec, 1},
299 { 0x001854f8, 7},
300 { 0x00185640, 41},
301 { 0x001856ec, 1},
302 { 0x001856f8, 7},
303 { 0x00185840, 41},
304 { 0x001858ec, 1},
305 { 0x001858f8, 7},
306 { 0x00185a40, 41},
307 { 0x00185aec, 1},
308 { 0x00185af8, 7},
309 { 0x00185c40, 41},
310 { 0x00185cec, 1},
311 { 0x00185cf8, 7},
312 { 0x00185e40, 41},
313 { 0x00185eec, 1},
314 { 0x00185ef8, 7},
315 { 0x001a0040, 41},
316 { 0x001a00ec, 1},
317 { 0x001a00f8, 7},
318 { 0x001a0240, 41},
319 { 0x001a02ec, 1},
320 { 0x001a02f8, 7},
321 { 0x001a0440, 41},
322 { 0x001a04ec, 1},
323 { 0x001a04f8, 7},
324 { 0x001a0640, 41},
325 { 0x001a06ec, 1},
326 { 0x001a06f8, 7},
327 { 0x001a0840, 41},
328 { 0x001a08ec, 1},
329 { 0x001a08f8, 7},
330 { 0x001a0a40, 41},
331 { 0x001a0aec, 1},
332 { 0x001a0af8, 7},
333 { 0x001a0c40, 41},
334 { 0x001a0cec, 1},
335 { 0x001a0cf8, 7},
336 { 0x001a0e40, 41},
337 { 0x001a0eec, 1},
338 { 0x001a0ef8, 7},
339 { 0x001a1040, 41},
340 { 0x001a10ec, 1},
341 { 0x001a10f8, 7},
342 { 0x001a1240, 41},
343 { 0x001a12ec, 1},
344 { 0x001a12f8, 7},
345 { 0x001a1440, 41},
346 { 0x001a14ec, 1},
347 { 0x001a14f8, 7},
348 { 0x001a1640, 41},
349 { 0x001a16ec, 1},
350 { 0x001a16f8, 7},
351 { 0x001a1840, 41},
352 { 0x001a18ec, 1},
353 { 0x001a18f8, 7},
354 { 0x001a1a40, 41},
355 { 0x001a1aec, 1},
356 { 0x001a1af8, 7},
357 { 0x001a1c40, 41},
358 { 0x001a1cec, 1},
359 { 0x001a1cf8, 7},
360 { 0x001a1e40, 41},
361 { 0x001a1eec, 1},
362 { 0x001a1ef8, 7},
363 { 0x001a2040, 41},
364 { 0x001a20ec, 1},
365 { 0x001a20f8, 7},
366 { 0x001a2240, 41},
367 { 0x001a22ec, 1},
368 { 0x001a22f8, 7},
369 { 0x001a2440, 41},
370 { 0x001a24ec, 1},
371 { 0x001a24f8, 7},
372 { 0x001a2640, 41},
373 { 0x001a26ec, 1},
374 { 0x001a26f8, 7},
375 { 0x001a2840, 41},
376 { 0x001a28ec, 1},
377 { 0x001a28f8, 7},
378 { 0x001a2a40, 41},
379 { 0x001a2aec, 1},
380 { 0x001a2af8, 7},
381 { 0x001a2c40, 41},
382 { 0x001a2cec, 1},
383 { 0x001a2cf8, 7},
384 { 0x001a2e40, 41},
385 { 0x001a2eec, 1},
386 { 0x001a2ef8, 7},
387 { 0x001a3040, 41},
388 { 0x001a30ec, 1},
389 { 0x001a30f8, 7},
390 { 0x001a3240, 41},
391 { 0x001a32ec, 1},
392 { 0x001a32f8, 7},
393 { 0x001a3440, 41},
394 { 0x001a34ec, 1},
395 { 0x001a34f8, 7},
396 { 0x001a3640, 41},
397 { 0x001a36ec, 1},
398 { 0x001a36f8, 7},
399 { 0x001a3840, 41},
400 { 0x001a38ec, 1},
401 { 0x001a38f8, 7},
402 { 0x001a3a40, 41},
403 { 0x001a3aec, 1},
404 { 0x001a3af8, 7},
405 { 0x001a3c40, 41},
406 { 0x001a3cec, 1},
407 { 0x001a3cf8, 7},
408 { 0x001a3e40, 41},
409 { 0x001a3eec, 1},
410 { 0x001a3ef8, 7},
411 { 0x001a4040, 41},
412 { 0x001a40ec, 1},
413 { 0x001a40f8, 7},
414 { 0x001a4240, 41},
415 { 0x001a42ec, 1},
416 { 0x001a42f8, 7},
417 { 0x001a4440, 41},
418 { 0x001a44ec, 1},
419 { 0x001a44f8, 7},
420 { 0x001a4640, 41},
421 { 0x001a46ec, 1},
422 { 0x001a46f8, 7},
423 { 0x001a4840, 41},
424 { 0x001a48ec, 1},
425 { 0x001a48f8, 7},
426 { 0x001a4a40, 41},
427 { 0x001a4aec, 1},
428 { 0x001a4af8, 7},
429 { 0x001a4c40, 41},
430 { 0x001a4cec, 1},
431 { 0x001a4cf8, 7},
432 { 0x001a4e40, 41},
433 { 0x001a4eec, 1},
434 { 0x001a4ef8, 7},
435 { 0x001a5040, 41},
436 { 0x001a50ec, 1},
437 { 0x001a50f8, 7},
438 { 0x001a5240, 41},
439 { 0x001a52ec, 1},
440 { 0x001a52f8, 7},
441 { 0x001a5440, 41},
442 { 0x001a54ec, 1},
443 { 0x001a54f8, 7},
444 { 0x001a5640, 41},
445 { 0x001a56ec, 1},
446 { 0x001a56f8, 7},
447 { 0x001a5840, 41},
448 { 0x001a58ec, 1},
449 { 0x001a58f8, 7},
450 { 0x001a5a40, 41},
451 { 0x001a5aec, 1},
452 { 0x001a5af8, 7},
453 { 0x001a5c40, 41},
454 { 0x001a5cec, 1},
455 { 0x001a5cf8, 7},
456 { 0x001a5e40, 41},
457 { 0x001a5eec, 1},
458 { 0x001a5ef8, 7},
459 { 0x001b0040, 41},
460 { 0x001b00ec, 1},
461 { 0x001b00f8, 7},
462 { 0x001b0240, 41},
463 { 0x001b02ec, 1},
464 { 0x001b02f8, 7},
465 { 0x001b0440, 41},
466 { 0x001b04ec, 1},
467 { 0x001b04f8, 7},
468 { 0x001b0640, 41},
469 { 0x001b06ec, 1},
470 { 0x001b06f8, 7},
471 { 0x001b0840, 41},
472 { 0x001b08ec, 1},
473 { 0x001b08f8, 7},
474 { 0x001b0a40, 41},
475 { 0x001b0aec, 1},
476 { 0x001b0af8, 7},
477 { 0x001b0c40, 41},
478 { 0x001b0cec, 1},
479 { 0x001b0cf8, 7},
480 { 0x001b0e40, 41},
481 { 0x001b0eec, 1},
482 { 0x001b0ef8, 7},
483 { 0x001b4000, 1},
484 { 0x001b4008, 1},
485 { 0x001b4010, 3},
486 { 0x001b4020, 3},
487 { 0x001b4030, 3},
488 { 0x001b4040, 3},
489 { 0x001b4050, 3},
490 { 0x001b4060, 4},
491 { 0x001b4074, 7},
492 { 0x001b4094, 3},
493 { 0x001b40a4, 1},
494 { 0x001b4100, 6},
495 { 0x001b4124, 2},
496 { 0x001b8000, 1},
497 { 0x001b8008, 1},
498 { 0x001b8010, 3},
499 { 0x001b8200, 1},
500 { 0x001b8208, 1},
501 { 0x001b8210, 3},
502 { 0x001b8400, 1},
503 { 0x001b8408, 1},
504 { 0x001b8410, 3},
505 { 0x001b8600, 1},
506 { 0x001b8608, 1},
507 { 0x001b8610, 3},
508 { 0x001b8800, 1},
509 { 0x001b8808, 1},
510 { 0x001b8810, 3},
511 { 0x001b8a00, 1},
512 { 0x001b8a08, 1},
513 { 0x001b8a10, 3},
514 { 0x001bc000, 1},
515 { 0x001bc008, 1},
516 { 0x001bc010, 3},
517 { 0x001bc200, 1},
518 { 0x001bc208, 1},
519 { 0x001bc210, 3},
520 { 0x001bc400, 1},
521 { 0x001bc408, 1},
522 { 0x001bc410, 3},
523 { 0x001bc600, 1},
524 { 0x001bc608, 1},
525 { 0x001bc610, 3},
526 { 0x001bc800, 1},
527 { 0x001bc808, 1},
528 { 0x001bc810, 3},
529 { 0x001bca00, 1},
530 { 0x001bca08, 1},
531 { 0x001bca10, 3},
532 { 0x001bd218, 1},
533 { 0x001be000, 1},
534 { 0x001be008, 1},
535 { 0x001be010, 3},
536 { 0x001be218, 1},
537 { 0x001bf218, 1},
538 { 0x001c0218, 1},
539 { 0x001c1218, 1},
540 { 0x001c80a8, 1},
541 { 0x001c9100, 1},
542 { 0x001cc0a8, 1},
543 { 0x001cd100, 1},
544 { 0x00400500, 1},
545 { 0x0040415c, 1},
546 { 0x00404468, 1},
547 { 0x00404498, 1},
548 { 0x00405800, 1},
549 { 0x00405840, 2},
550 { 0x00405850, 1},
551 { 0x00405908, 1},
552 { 0x00405a00, 1},
553 { 0x00405b40, 1},
554 { 0x00405b50, 1},
555 { 0x00406024, 5},
556 { 0x00407010, 1},
557 { 0x00407808, 1},
558 { 0x0040803c, 1},
559 { 0x00408804, 1},
560 { 0x0040880c, 1},
561 { 0x00408900, 2},
562 { 0x00408910, 1},
563 { 0x00408944, 1},
564 { 0x00408984, 1},
565 { 0x004090a8, 1},
566 { 0x004098a0, 1},
567 { 0x00409b00, 1},
568 { 0x0041000c, 1},
569 { 0x00410110, 1},
570 { 0x00410184, 1},
571 { 0x0041040c, 1},
572 { 0x00410510, 1},
573 { 0x00410584, 1},
574 { 0x0041080c, 1},
575 { 0x00410910, 1},
576 { 0x00410984, 1},
577 { 0x00410c0c, 1},
578 { 0x00410d10, 1},
579 { 0x00410d84, 1},
580 { 0x0041100c, 1},
581 { 0x00411110, 1},
582 { 0x00411184, 1},
583 { 0x0041140c, 1},
584 { 0x00411510, 1},
585 { 0x00411584, 1},
586 { 0x0041180c, 1},
587 { 0x00411910, 1},
588 { 0x00411984, 1},
589 { 0x00411c0c, 1},
590 { 0x00411d10, 1},
591 { 0x00411d84, 1},
592 { 0x0041200c, 1},
593 { 0x00412110, 1},
594 { 0x00412184, 1},
595 { 0x0041240c, 1},
596 { 0x00412510, 1},
597 { 0x00412584, 1},
598 { 0x0041280c, 1},
599 { 0x00412910, 1},
600 { 0x00412984, 1},
601 { 0x00412c0c, 1},
602 { 0x00412d10, 1},
603 { 0x00412d84, 1},
604 { 0x00418000, 1},
605 { 0x00418008, 1},
606 { 0x00418380, 2},
607 { 0x00418400, 2},
608 { 0x004184a0, 1},
609 { 0x00418604, 1},
610 { 0x00418680, 1},
611 { 0x00418704, 1},
612 { 0x00418714, 1},
613 { 0x00418800, 1},
614 { 0x0041881c, 1},
615 { 0x00418830, 1},
616 { 0x00418884, 1},
617 { 0x004188b0, 1},
618 { 0x004188c8, 3},
619 { 0x004188fc, 1},
620 { 0x00418b04, 1},
621 { 0x00418c04, 1},
622 { 0x00418c10, 8},
623 { 0x00418c88, 1},
624 { 0x00418d00, 1},
625 { 0x00418e00, 1},
626 { 0x00418e08, 1},
627 { 0x00418e34, 1},
628 { 0x00418e40, 4},
629 { 0x00418e58, 16},
630 { 0x00418f08, 1},
631 { 0x00419000, 1},
632 { 0x0041900c, 1},
633 { 0x00419018, 1},
634 { 0x00419854, 1},
635 { 0x00419864, 1},
636 { 0x00419a04, 2},
637 { 0x00419a14, 1},
638 { 0x00419ab0, 1},
639 { 0x00419ab8, 3},
640 { 0x00419c0c, 1},
641 { 0x00419c8c, 2},
642 { 0x00419d00, 1},
643 { 0x00419d08, 2},
644 { 0x00419e00, 11},
645 { 0x00419e34, 2},
646 { 0x00419e44, 11},
647 { 0x00419e74, 10},
648 { 0x00419ea4, 1},
649 { 0x00419eac, 2},
650 { 0x00419ee8, 1},
651 { 0x00419ef0, 28},
652 { 0x00419f70, 1},
653 { 0x00419f78, 2},
654 { 0x00419f98, 2},
655 { 0x00419fdc, 1},
656 { 0x0041a02c, 2},
657 { 0x0041a0a0, 1},
658 { 0x0041a0a8, 1},
659 { 0x0041a890, 2},
660 { 0x0041a8a0, 3},
661 { 0x0041a8b0, 2},
662 { 0x0041b014, 1},
663 { 0x0041b0cc, 1},
664 { 0x0041b1dc, 1},
665 { 0x0041b214, 1},
666 { 0x0041b2cc, 1},
667 { 0x0041b3dc, 1},
668 { 0x0041b414, 1},
669 { 0x0041b4cc, 1},
670 { 0x0041b5dc, 1},
671 { 0x0041be0c, 3},
672 { 0x0041becc, 1},
673 { 0x0041bfdc, 1},
674 { 0x0041c054, 1},
675 { 0x0041c2b0, 1},
676 { 0x0041c2b8, 3},
677 { 0x0041c40c, 1},
678 { 0x0041c48c, 2},
679 { 0x0041c500, 1},
680 { 0x0041c508, 2},
681 { 0x0041c600, 11},
682 { 0x0041c634, 2},
683 { 0x0041c644, 11},
684 { 0x0041c674, 10},
685 { 0x0041c6a4, 1},
686 { 0x0041c6ac, 2},
687 { 0x0041c6e8, 1},
688 { 0x0041c6f0, 28},
689 { 0x0041c770, 1},
690 { 0x0041c778, 2},
691 { 0x0041c798, 2},
692 { 0x0041c7dc, 1},
693 { 0x0041c854, 1},
694 { 0x0041cab0, 1},
695 { 0x0041cab8, 3},
696 { 0x0041cc0c, 1},
697 { 0x0041cc8c, 2},
698 { 0x0041cd00, 1},
699 { 0x0041cd08, 2},
700 { 0x0041ce00, 11},
701 { 0x0041ce34, 2},
702 { 0x0041ce44, 11},
703 { 0x0041ce74, 10},
704 { 0x0041cea4, 1},
705 { 0x0041ceac, 2},
706 { 0x0041cee8, 1},
707 { 0x0041cef0, 28},
708 { 0x0041cf70, 1},
709 { 0x0041cf78, 2},
710 { 0x0041cf98, 2},
711 { 0x0041cfdc, 1},
712 { 0x0041d054, 1},
713 { 0x0041d2b0, 1},
714 { 0x0041d2b8, 3},
715 { 0x0041d40c, 1},
716 { 0x0041d48c, 2},
717 { 0x0041d500, 1},
718 { 0x0041d508, 2},
719 { 0x0041d600, 11},
720 { 0x0041d634, 2},
721 { 0x0041d644, 11},
722 { 0x0041d674, 10},
723 { 0x0041d6a4, 1},
724 { 0x0041d6ac, 2},
725 { 0x0041d6e8, 1},
726 { 0x0041d6f0, 28},
727 { 0x0041d770, 1},
728 { 0x0041d778, 2},
729 { 0x0041d798, 2},
730 { 0x0041d7dc, 1},
731 { 0x0041d854, 1},
732 { 0x0041dab0, 1},
733 { 0x0041dab8, 3},
734 { 0x0041dc0c, 1},
735 { 0x0041dc8c, 2},
736 { 0x0041dd00, 1},
737 { 0x0041dd08, 2},
738 { 0x0041de00, 11},
739 { 0x0041de34, 2},
740 { 0x0041de44, 11},
741 { 0x0041de74, 10},
742 { 0x0041dea4, 1},
743 { 0x0041deac, 2},
744 { 0x0041dee8, 1},
745 { 0x0041def0, 28},
746 { 0x0041df70, 1},
747 { 0x0041df78, 2},
748 { 0x0041df98, 2},
749 { 0x0041dfdc, 1},
750 { 0x0041e054, 1},
751 { 0x0041e2b0, 1},
752 { 0x0041e2b8, 3},
753 { 0x0041e40c, 1},
754 { 0x0041e48c, 2},
755 { 0x0041e500, 1},
756 { 0x0041e508, 2},
757 { 0x0041e600, 11},
758 { 0x0041e634, 2},
759 { 0x0041e644, 11},
760 { 0x0041e674, 10},
761 { 0x0041e6a4, 1},
762 { 0x0041e6ac, 2},
763 { 0x0041e6e8, 1},
764 { 0x0041e6f0, 28},
765 { 0x0041e770, 1},
766 { 0x0041e778, 2},
767 { 0x0041e798, 2},
768 { 0x0041e7dc, 1},
769 { 0x00500384, 1},
770 { 0x005004a0, 1},
771 { 0x00500604, 1},
772 { 0x00500680, 1},
773 { 0x00500714, 1},
774 { 0x0050081c, 1},
775 { 0x00500884, 1},
776 { 0x005008b0, 1},
777 { 0x005008c8, 3},
778 { 0x005008fc, 1},
779 { 0x00500b04, 1},
780 { 0x00500c04, 1},
781 { 0x00500c10, 8},
782 { 0x00500c88, 1},
783 { 0x00500d00, 1},
784 { 0x00500e08, 1},
785 { 0x00500f08, 1},
786 { 0x00501000, 1},
787 { 0x0050100c, 1},
788 { 0x00501018, 1},
789 { 0x00501854, 1},
790 { 0x00501ab0, 1},
791 { 0x00501ab8, 3},
792 { 0x00501c0c, 1},
793 { 0x00501c8c, 2},
794 { 0x00501d00, 1},
795 { 0x00501d08, 2},
796 { 0x00501e00, 11},
797 { 0x00501e34, 2},
798 { 0x00501e44, 11},
799 { 0x00501e74, 10},
800 { 0x00501ea4, 1},
801 { 0x00501eac, 2},
802 { 0x00501ee8, 1},
803 { 0x00501ef0, 28},
804 { 0x00501f70, 1},
805 { 0x00501f78, 2},
806 { 0x00501f98, 2},
807 { 0x00501fdc, 1},
808 { 0x0050202c, 2},
809 { 0x005020a0, 1},
810 { 0x005020a8, 1},
811 { 0x00502890, 2},
812 { 0x005028a0, 3},
813 { 0x005028b0, 2},
814 { 0x00503014, 1},
815 { 0x005030cc, 1},
816 { 0x005031dc, 1},
817 { 0x00503214, 1},
818 { 0x005032cc, 1},
819 { 0x005033dc, 1},
820 { 0x00503414, 1},
821 { 0x005034cc, 1},
822 { 0x005035dc, 1},
823 { 0x00503e14, 1},
824 { 0x00503ecc, 1},
825 { 0x00503fdc, 1},
826 { 0x00504054, 1},
827 { 0x005042b0, 1},
828 { 0x005042b8, 3},
829 { 0x0050440c, 1},
830 { 0x0050448c, 2},
831 { 0x00504500, 1},
832 { 0x00504508, 2},
833 { 0x00504600, 11},
834 { 0x00504634, 2},
835 { 0x00504644, 11},
836 { 0x00504674, 10},
837 { 0x005046a4, 1},
838 { 0x005046ac, 2},
839 { 0x005046e8, 1},
840 { 0x005046f0, 28},
841 { 0x00504770, 1},
842 { 0x00504778, 2},
843 { 0x00504798, 2},
844 { 0x005047dc, 1},
845 { 0x00504854, 1},
846 { 0x00504ab0, 1},
847 { 0x00504ab8, 3},
848 { 0x00504c0c, 1},
849 { 0x00504c8c, 2},
850 { 0x00504d00, 1},
851 { 0x00504d08, 2},
852 { 0x00504e00, 11},
853 { 0x00504e34, 2},
854 { 0x00504e44, 11},
855 { 0x00504e74, 10},
856 { 0x00504ea4, 1},
857 { 0x00504eac, 2},
858 { 0x00504ee8, 1},
859 { 0x00504ef0, 28},
860 { 0x00504f70, 1},
861 { 0x00504f78, 2},
862 { 0x00504f98, 2},
863 { 0x00504fdc, 1},
864 { 0x00505054, 1},
865 { 0x005052b0, 1},
866 { 0x005052b8, 3},
867 { 0x0050540c, 1},
868 { 0x0050548c, 2},
869 { 0x00505500, 1},
870 { 0x00505508, 2},
871 { 0x00505600, 11},
872 { 0x00505634, 2},
873 { 0x00505644, 11},
874 { 0x00505674, 10},
875 { 0x005056a4, 1},
876 { 0x005056ac, 2},
877 { 0x005056e8, 1},
878 { 0x005056f0, 28},
879 { 0x00505770, 1},
880 { 0x00505778, 2},
881 { 0x00505798, 2},
882 { 0x005057dc, 1},
883 { 0x00505854, 1},
884 { 0x00505ab0, 1},
885 { 0x00505ab8, 3},
886 { 0x00505c0c, 1},
887 { 0x00505c8c, 2},
888 { 0x00505d00, 1},
889 { 0x00505d08, 2},
890 { 0x00505e00, 11},
891 { 0x00505e34, 2},
892 { 0x00505e44, 11},
893 { 0x00505e74, 10},
894 { 0x00505ea4, 1},
895 { 0x00505eac, 2},
896 { 0x00505ee8, 1},
897 { 0x00505ef0, 28},
898 { 0x00505f70, 1},
899 { 0x00505f78, 2},
900 { 0x00505f98, 2},
901 { 0x00505fdc, 1},
902 { 0x00506054, 1},
903 { 0x005062b0, 1},
904 { 0x005062b8, 3},
905 { 0x0050640c, 1},
906 { 0x0050648c, 2},
907 { 0x00506500, 1},
908 { 0x00506508, 2},
909 { 0x00506600, 11},
910 { 0x00506634, 2},
911 { 0x00506644, 11},
912 { 0x00506674, 10},
913 { 0x005066a4, 1},
914 { 0x005066ac, 2},
915 { 0x005066e8, 1},
916 { 0x005066f0, 28},
917 { 0x00506770, 1},
918 { 0x00506778, 2},
919 { 0x00506798, 2},
920 { 0x005067dc, 1},
921 { 0x00508384, 1},
922 { 0x005084a0, 1},
923 { 0x00508604, 1},
924 { 0x00508680, 1},
925 { 0x00508714, 1},
926 { 0x0050881c, 1},
927 { 0x00508884, 1},
928 { 0x005088b0, 1},
929 { 0x005088c8, 2},
930 { 0x00508b04, 1},
931 { 0x00508c04, 1},
932 { 0x00508c10, 8},
933 { 0x00508c88, 1},
934 { 0x00508d00, 1},
935 { 0x00508e08, 1},
936 { 0x00508f08, 1},
937 { 0x00509000, 1},
938 { 0x0050900c, 1},
939 { 0x00509018, 1},
940 { 0x00509854, 1},
941 { 0x00509ab0, 1},
942 { 0x00509ab8, 3},
943 { 0x00509c0c, 1},
944 { 0x00509c8c, 2},
945 { 0x00509d00, 1},
946 { 0x00509d08, 2},
947 { 0x00509e00, 11},
948 { 0x00509e34, 2},
949 { 0x00509e44, 11},
950 { 0x00509e74, 10},
951 { 0x00509ea4, 1},
952 { 0x00509eac, 2},
953 { 0x00509ee8, 1},
954 { 0x00509ef0, 28},
955 { 0x00509f70, 1},
956 { 0x00509f78, 2},
957 { 0x00509f98, 2},
958 { 0x00509fdc, 1},
959 { 0x0050a02c, 2},
960 { 0x0050a0a0, 1},
961 { 0x0050a0a8, 1},
962 { 0x0050a890, 2},
963 { 0x0050a8a0, 3},
964 { 0x0050a8b0, 2},
965 { 0x0050b014, 1},
966 { 0x0050b0cc, 1},
967 { 0x0050b1dc, 1},
968 { 0x0050b214, 1},
969 { 0x0050b2cc, 1},
970 { 0x0050b3dc, 1},
971 { 0x0050b414, 1},
972 { 0x0050b4cc, 1},
973 { 0x0050b5dc, 1},
974 { 0x0050be14, 1},
975 { 0x0050becc, 1},
976 { 0x0050bfdc, 1},
977 { 0x0050c054, 1},
978 { 0x0050c2b0, 1},
979 { 0x0050c2b8, 3},
980 { 0x0050c40c, 1},
981 { 0x0050c48c, 2},
982 { 0x0050c500, 1},
983 { 0x0050c508, 2},
984 { 0x0050c600, 11},
985 { 0x0050c634, 2},
986 { 0x0050c644, 11},
987 { 0x0050c674, 10},
988 { 0x0050c6a4, 1},
989 { 0x0050c6ac, 2},
990 { 0x0050c6e8, 1},
991 { 0x0050c6f0, 28},
992 { 0x0050c770, 1},
993 { 0x0050c778, 2},
994 { 0x0050c798, 2},
995 { 0x0050c7dc, 1},
996 { 0x0050c854, 1},
997 { 0x0050cab0, 1},
998 { 0x0050cab8, 3},
999 { 0x0050cc0c, 1},
1000 { 0x0050cc8c, 2},
1001 { 0x0050cd00, 1},
1002 { 0x0050cd08, 2},
1003 { 0x0050ce00, 11},
1004 { 0x0050ce34, 2},
1005 { 0x0050ce44, 11},
1006 { 0x0050ce74, 10},
1007 { 0x0050cea4, 1},
1008 { 0x0050ceac, 2},
1009 { 0x0050cee8, 1},
1010 { 0x0050cef0, 28},
1011 { 0x0050cf70, 1},
1012 { 0x0050cf78, 2},
1013 { 0x0050cf98, 2},
1014 { 0x0050cfdc, 1},
1015 { 0x0050d054, 1},
1016 { 0x0050d2b0, 1},
1017 { 0x0050d2b8, 3},
1018 { 0x0050d40c, 1},
1019 { 0x0050d48c, 2},
1020 { 0x0050d500, 1},
1021 { 0x0050d508, 2},
1022 { 0x0050d600, 11},
1023 { 0x0050d634, 2},
1024 { 0x0050d644, 11},
1025 { 0x0050d674, 10},
1026 { 0x0050d6a4, 1},
1027 { 0x0050d6ac, 2},
1028 { 0x0050d6e8, 1},
1029 { 0x0050d6f0, 28},
1030 { 0x0050d770, 1},
1031 { 0x0050d778, 2},
1032 { 0x0050d798, 2},
1033 { 0x0050d7dc, 1},
1034 { 0x0050d854, 1},
1035 { 0x0050dab0, 1},
1036 { 0x0050dab8, 3},
1037 { 0x0050dc0c, 1},
1038 { 0x0050dc8c, 2},
1039 { 0x0050dd00, 1},
1040 { 0x0050dd08, 2},
1041 { 0x0050de00, 11},
1042 { 0x0050de34, 2},
1043 { 0x0050de44, 11},
1044 { 0x0050de74, 10},
1045 { 0x0050dea4, 1},
1046 { 0x0050deac, 2},
1047 { 0x0050dee8, 1},
1048 { 0x0050def0, 28},
1049 { 0x0050df70, 1},
1050 { 0x0050df78, 2},
1051 { 0x0050df98, 2},
1052 { 0x0050dfdc, 1},
1053 { 0x0050e054, 1},
1054 { 0x0050e2b0, 1},
1055 { 0x0050e2b8, 3},
1056 { 0x0050e40c, 1},
1057 { 0x0050e48c, 2},
1058 { 0x0050e500, 1},
1059 { 0x0050e508, 2},
1060 { 0x0050e600, 11},
1061 { 0x0050e634, 2},
1062 { 0x0050e644, 11},
1063 { 0x0050e674, 10},
1064 { 0x0050e6a4, 1},
1065 { 0x0050e6ac, 2},
1066 { 0x0050e6e8, 1},
1067 { 0x0050e6f0, 28},
1068 { 0x0050e770, 1},
1069 { 0x0050e778, 2},
1070 { 0x0050e798, 2},
1071 { 0x0050e7dc, 1},
1072 { 0x00510384, 1},
1073 { 0x005104a0, 1},
1074 { 0x00510604, 1},
1075 { 0x00510680, 1},
1076 { 0x00510714, 1},
1077 { 0x0051081c, 1},
1078 { 0x00510884, 1},
1079 { 0x005108b0, 1},
1080 { 0x005108c8, 2},
1081 { 0x00510b04, 1},
1082 { 0x00510c04, 1},
1083 { 0x00510c10, 8},
1084 { 0x00510c88, 1},
1085 { 0x00510d00, 1},
1086 { 0x00510e08, 1},
1087 { 0x00510f08, 1},
1088 { 0x00511000, 1},
1089 { 0x0051100c, 1},
1090 { 0x00511018, 1},
1091 { 0x00511854, 1},
1092 { 0x00511ab0, 1},
1093 { 0x00511ab8, 3},
1094 { 0x00511c0c, 1},
1095 { 0x00511c8c, 2},
1096 { 0x00511d00, 1},
1097 { 0x00511d08, 2},
1098 { 0x00511e00, 11},
1099 { 0x00511e34, 2},
1100 { 0x00511e44, 11},
1101 { 0x00511e74, 10},
1102 { 0x00511ea4, 1},
1103 { 0x00511eac, 2},
1104 { 0x00511ee8, 1},
1105 { 0x00511ef0, 28},
1106 { 0x00511f70, 1},
1107 { 0x00511f78, 2},
1108 { 0x00511f98, 2},
1109 { 0x00511fdc, 1},
1110 { 0x0051202c, 2},
1111 { 0x005120a0, 1},
1112 { 0x005120a8, 1},
1113 { 0x00512890, 2},
1114 { 0x005128a0, 3},
1115 { 0x005128b0, 2},
1116 { 0x00513014, 1},
1117 { 0x005130cc, 1},
1118 { 0x005131dc, 1},
1119 { 0x00513214, 1},
1120 { 0x005132cc, 1},
1121 { 0x005133dc, 1},
1122 { 0x00513414, 1},
1123 { 0x005134cc, 1},
1124 { 0x005135dc, 1},
1125 { 0x00513e14, 1},
1126 { 0x00513ecc, 1},
1127 { 0x00513fdc, 1},
1128 { 0x00514054, 1},
1129 { 0x005142b0, 1},
1130 { 0x005142b8, 3},
1131 { 0x0051440c, 1},
1132 { 0x0051448c, 2},
1133 { 0x00514500, 1},
1134 { 0x00514508, 2},
1135 { 0x00514600, 11},
1136 { 0x00514634, 2},
1137 { 0x00514644, 11},
1138 { 0x00514674, 10},
1139 { 0x005146a4, 1},
1140 { 0x005146ac, 2},
1141 { 0x005146e8, 1},
1142 { 0x005146f0, 28},
1143 { 0x00514770, 1},
1144 { 0x00514778, 2},
1145 { 0x00514798, 2},
1146 { 0x005147dc, 1},
1147 { 0x00514854, 1},
1148 { 0x00514ab0, 1},
1149 { 0x00514ab8, 3},
1150 { 0x00514c0c, 1},
1151 { 0x00514c8c, 2},
1152 { 0x00514d00, 1},
1153 { 0x00514d08, 2},
1154 { 0x00514e00, 11},
1155 { 0x00514e34, 2},
1156 { 0x00514e44, 11},
1157 { 0x00514e74, 10},
1158 { 0x00514ea4, 1},
1159 { 0x00514eac, 2},
1160 { 0x00514ee8, 1},
1161 { 0x00514ef0, 28},
1162 { 0x00514f70, 1},
1163 { 0x00514f78, 2},
1164 { 0x00514f98, 2},
1165 { 0x00514fdc, 1},
1166 { 0x00515054, 1},
1167 { 0x005152b0, 1},
1168 { 0x005152b8, 3},
1169 { 0x0051540c, 1},
1170 { 0x0051548c, 2},
1171 { 0x00515500, 1},
1172 { 0x00515508, 2},
1173 { 0x00515600, 11},
1174 { 0x00515634, 2},
1175 { 0x00515644, 11},
1176 { 0x00515674, 10},
1177 { 0x005156a4, 1},
1178 { 0x005156ac, 2},
1179 { 0x005156e8, 1},
1180 { 0x005156f0, 28},
1181 { 0x00515770, 1},
1182 { 0x00515778, 2},
1183 { 0x00515798, 2},
1184 { 0x005157dc, 1},
1185 { 0x00515854, 1},
1186 { 0x00515ab0, 1},
1187 { 0x00515ab8, 3},
1188 { 0x00515c0c, 1},
1189 { 0x00515c8c, 2},
1190 { 0x00515d00, 1},
1191 { 0x00515d08, 2},
1192 { 0x00515e00, 11},
1193 { 0x00515e34, 2},
1194 { 0x00515e44, 11},
1195 { 0x00515e74, 10},
1196 { 0x00515ea4, 1},
1197 { 0x00515eac, 2},
1198 { 0x00515ee8, 1},
1199 { 0x00515ef0, 28},
1200 { 0x00515f70, 1},
1201 { 0x00515f78, 2},
1202 { 0x00515f98, 2},
1203 { 0x00515fdc, 1},
1204 { 0x00516054, 1},
1205 { 0x005162b0, 1},
1206 { 0x005162b8, 3},
1207 { 0x0051640c, 1},
1208 { 0x0051648c, 2},
1209 { 0x00516500, 1},
1210 { 0x00516508, 2},
1211 { 0x00516600, 11},
1212 { 0x00516634, 2},
1213 { 0x00516644, 11},
1214 { 0x00516674, 10},
1215 { 0x005166a4, 1},
1216 { 0x005166ac, 2},
1217 { 0x005166e8, 1},
1218 { 0x005166f0, 28},
1219 { 0x00516770, 1},
1220 { 0x00516778, 2},
1221 { 0x00516798, 2},
1222 { 0x005167dc, 1},
1223 { 0x00518384, 1},
1224 { 0x005184a0, 1},
1225 { 0x00518604, 1},
1226 { 0x00518680, 1},
1227 { 0x00518714, 1},
1228 { 0x0051881c, 1},
1229 { 0x00518884, 1},
1230 { 0x005188b0, 1},
1231 { 0x005188c8, 2},
1232 { 0x00518b04, 1},
1233 { 0x00518c04, 1},
1234 { 0x00518c10, 8},
1235 { 0x00518c88, 1},
1236 { 0x00518d00, 1},
1237 { 0x00518e08, 1},
1238 { 0x00518f08, 1},
1239 { 0x00519000, 1},
1240 { 0x0051900c, 1},
1241 { 0x00519018, 1},
1242 { 0x00519854, 1},
1243 { 0x00519ab0, 1},
1244 { 0x00519ab8, 3},
1245 { 0x00519c0c, 1},
1246 { 0x00519c8c, 2},
1247 { 0x00519d00, 1},
1248 { 0x00519d08, 2},
1249 { 0x00519e00, 11},
1250 { 0x00519e34, 2},
1251 { 0x00519e44, 11},
1252 { 0x00519e74, 10},
1253 { 0x00519ea4, 1},
1254 { 0x00519eac, 2},
1255 { 0x00519ee8, 1},
1256 { 0x00519ef0, 28},
1257 { 0x00519f70, 1},
1258 { 0x00519f78, 2},
1259 { 0x00519f98, 2},
1260 { 0x00519fdc, 1},
1261 { 0x0051a02c, 2},
1262 { 0x0051a0a0, 1},
1263 { 0x0051a0a8, 1},
1264 { 0x0051a890, 2},
1265 { 0x0051a8a0, 3},
1266 { 0x0051a8b0, 2},
1267 { 0x0051b014, 1},
1268 { 0x0051b0cc, 1},
1269 { 0x0051b1dc, 1},
1270 { 0x0051b214, 1},
1271 { 0x0051b2cc, 1},
1272 { 0x0051b3dc, 1},
1273 { 0x0051b414, 1},
1274 { 0x0051b4cc, 1},
1275 { 0x0051b5dc, 1},
1276 { 0x0051be14, 1},
1277 { 0x0051becc, 1},
1278 { 0x0051bfdc, 1},
1279 { 0x0051c054, 1},
1280 { 0x0051c2b0, 1},
1281 { 0x0051c2b8, 3},
1282 { 0x0051c40c, 1},
1283 { 0x0051c48c, 2},
1284 { 0x0051c500, 1},
1285 { 0x0051c508, 2},
1286 { 0x0051c600, 11},
1287 { 0x0051c634, 2},
1288 { 0x0051c644, 11},
1289 { 0x0051c674, 10},
1290 { 0x0051c6a4, 1},
1291 { 0x0051c6ac, 2},
1292 { 0x0051c6e8, 1},
1293 { 0x0051c6f0, 28},
1294 { 0x0051c770, 1},
1295 { 0x0051c778, 2},
1296 { 0x0051c798, 2},
1297 { 0x0051c7dc, 1},
1298 { 0x0051c854, 1},
1299 { 0x0051cab0, 1},
1300 { 0x0051cab8, 3},
1301 { 0x0051cc0c, 1},
1302 { 0x0051cc8c, 2},
1303 { 0x0051cd00, 1},
1304 { 0x0051cd08, 2},
1305 { 0x0051ce00, 11},
1306 { 0x0051ce34, 2},
1307 { 0x0051ce44, 11},
1308 { 0x0051ce74, 10},
1309 { 0x0051cea4, 1},
1310 { 0x0051ceac, 2},
1311 { 0x0051cee8, 1},
1312 { 0x0051cef0, 28},
1313 { 0x0051cf70, 1},
1314 { 0x0051cf78, 2},
1315 { 0x0051cf98, 2},
1316 { 0x0051cfdc, 1},
1317 { 0x0051d054, 1},
1318 { 0x0051d2b0, 1},
1319 { 0x0051d2b8, 3},
1320 { 0x0051d40c, 1},
1321 { 0x0051d48c, 2},
1322 { 0x0051d500, 1},
1323 { 0x0051d508, 2},
1324 { 0x0051d600, 11},
1325 { 0x0051d634, 2},
1326 { 0x0051d644, 11},
1327 { 0x0051d674, 10},
1328 { 0x0051d6a4, 1},
1329 { 0x0051d6ac, 2},
1330 { 0x0051d6e8, 1},
1331 { 0x0051d6f0, 28},
1332 { 0x0051d770, 1},
1333 { 0x0051d778, 2},
1334 { 0x0051d798, 2},
1335 { 0x0051d7dc, 1},
1336 { 0x0051d854, 1},
1337 { 0x0051dab0, 1},
1338 { 0x0051dab8, 3},
1339 { 0x0051dc0c, 1},
1340 { 0x0051dc8c, 2},
1341 { 0x0051dd00, 1},
1342 { 0x0051dd08, 2},
1343 { 0x0051de00, 11},
1344 { 0x0051de34, 2},
1345 { 0x0051de44, 11},
1346 { 0x0051de74, 10},
1347 { 0x0051dea4, 1},
1348 { 0x0051deac, 2},
1349 { 0x0051dee8, 1},
1350 { 0x0051def0, 28},
1351 { 0x0051df70, 1},
1352 { 0x0051df78, 2},
1353 { 0x0051df98, 2},
1354 { 0x0051dfdc, 1},
1355 { 0x0051e054, 1},
1356 { 0x0051e2b0, 1},
1357 { 0x0051e2b8, 3},
1358 { 0x0051e40c, 1},
1359 { 0x0051e48c, 2},
1360 { 0x0051e500, 1},
1361 { 0x0051e508, 2},
1362 { 0x0051e600, 11},
1363 { 0x0051e634, 2},
1364 { 0x0051e644, 11},
1365 { 0x0051e674, 10},
1366 { 0x0051e6a4, 1},
1367 { 0x0051e6ac, 2},
1368 { 0x0051e6e8, 1},
1369 { 0x0051e6f0, 28},
1370 { 0x0051e770, 1},
1371 { 0x0051e778, 2},
1372 { 0x0051e798, 2},
1373 { 0x0051e7dc, 1},
1374 { 0x00520384, 1},
1375 { 0x005204a0, 1},
1376 { 0x00520604, 1},
1377 { 0x00520680, 1},
1378 { 0x00520714, 1},
1379 { 0x0052081c, 1},
1380 { 0x00520884, 1},
1381 { 0x005208b0, 1},
1382 { 0x005208c8, 2},
1383 { 0x00520b04, 1},
1384 { 0x00520c04, 1},
1385 { 0x00520c10, 8},
1386 { 0x00520c88, 1},
1387 { 0x00520d00, 1},
1388 { 0x00520e08, 1},
1389 { 0x00520f08, 1},
1390 { 0x00521000, 1},
1391 { 0x0052100c, 1},
1392 { 0x00521018, 1},
1393 { 0x00521854, 1},
1394 { 0x00521ab0, 1},
1395 { 0x00521ab8, 3},
1396 { 0x00521c0c, 1},
1397 { 0x00521c8c, 2},
1398 { 0x00521d00, 1},
1399 { 0x00521d08, 2},
1400 { 0x00521e00, 11},
1401 { 0x00521e34, 2},
1402 { 0x00521e44, 11},
1403 { 0x00521e74, 10},
1404 { 0x00521ea4, 1},
1405 { 0x00521eac, 2},
1406 { 0x00521ee8, 1},
1407 { 0x00521ef0, 28},
1408 { 0x00521f70, 1},
1409 { 0x00521f78, 2},
1410 { 0x00521f98, 2},
1411 { 0x00521fdc, 1},
1412 { 0x0052202c, 2},
1413 { 0x005220a0, 1},
1414 { 0x005220a8, 1},
1415 { 0x00522890, 2},
1416 { 0x005228a0, 3},
1417 { 0x005228b0, 2},
1418 { 0x00523014, 1},
1419 { 0x005230cc, 1},
1420 { 0x005231dc, 1},
1421 { 0x00523214, 1},
1422 { 0x005232cc, 1},
1423 { 0x005233dc, 1},
1424 { 0x00523414, 1},
1425 { 0x005234cc, 1},
1426 { 0x005235dc, 1},
1427 { 0x00523e14, 1},
1428 { 0x00523ecc, 1},
1429 { 0x00523fdc, 1},
1430 { 0x00524054, 1},
1431 { 0x005242b0, 1},
1432 { 0x005242b8, 3},
1433 { 0x0052440c, 1},
1434 { 0x0052448c, 2},
1435 { 0x00524500, 1},
1436 { 0x00524508, 2},
1437 { 0x00524600, 11},
1438 { 0x00524634, 2},
1439 { 0x00524644, 11},
1440 { 0x00524674, 10},
1441 { 0x005246a4, 1},
1442 { 0x005246ac, 2},
1443 { 0x005246e8, 1},
1444 { 0x005246f0, 28},
1445 { 0x00524770, 1},
1446 { 0x00524778, 2},
1447 { 0x00524798, 2},
1448 { 0x005247dc, 1},
1449 { 0x00524854, 1},
1450 { 0x00524ab0, 1},
1451 { 0x00524ab8, 3},
1452 { 0x00524c0c, 1},
1453 { 0x00524c8c, 2},
1454 { 0x00524d00, 1},
1455 { 0x00524d08, 2},
1456 { 0x00524e00, 11},
1457 { 0x00524e34, 2},
1458 { 0x00524e44, 11},
1459 { 0x00524e74, 10},
1460 { 0x00524ea4, 1},
1461 { 0x00524eac, 2},
1462 { 0x00524ee8, 1},
1463 { 0x00524ef0, 28},
1464 { 0x00524f70, 1},
1465 { 0x00524f78, 2},
1466 { 0x00524f98, 2},
1467 { 0x00524fdc, 1},
1468 { 0x00525054, 1},
1469 { 0x005252b0, 1},
1470 { 0x005252b8, 3},
1471 { 0x0052540c, 1},
1472 { 0x0052548c, 2},
1473 { 0x00525500, 1},
1474 { 0x00525508, 2},
1475 { 0x00525600, 11},
1476 { 0x00525634, 2},
1477 { 0x00525644, 11},
1478 { 0x00525674, 10},
1479 { 0x005256a4, 1},
1480 { 0x005256ac, 2},
1481 { 0x005256e8, 1},
1482 { 0x005256f0, 28},
1483 { 0x00525770, 1},
1484 { 0x00525778, 2},
1485 { 0x00525798, 2},
1486 { 0x005257dc, 1},
1487 { 0x00525854, 1},
1488 { 0x00525ab0, 1},
1489 { 0x00525ab8, 3},
1490 { 0x00525c0c, 1},
1491 { 0x00525c8c, 2},
1492 { 0x00525d00, 1},
1493 { 0x00525d08, 2},
1494 { 0x00525e00, 11},
1495 { 0x00525e34, 2},
1496 { 0x00525e44, 11},
1497 { 0x00525e74, 10},
1498 { 0x00525ea4, 1},
1499 { 0x00525eac, 2},
1500 { 0x00525ee8, 1},
1501 { 0x00525ef0, 28},
1502 { 0x00525f70, 1},
1503 { 0x00525f78, 2},
1504 { 0x00525f98, 2},
1505 { 0x00525fdc, 1},
1506 { 0x00526054, 1},
1507 { 0x005262b0, 1},
1508 { 0x005262b8, 3},
1509 { 0x0052640c, 1},
1510 { 0x0052648c, 2},
1511 { 0x00526500, 1},
1512 { 0x00526508, 2},
1513 { 0x00526600, 11},
1514 { 0x00526634, 2},
1515 { 0x00526644, 11},
1516 { 0x00526674, 10},
1517 { 0x005266a4, 1},
1518 { 0x005266ac, 2},
1519 { 0x005266e8, 1},
1520 { 0x005266f0, 28},
1521 { 0x00526770, 1},
1522 { 0x00526778, 2},
1523 { 0x00526798, 2},
1524 { 0x005267dc, 1},
1525 { 0x00528384, 1},
1526 { 0x005284a0, 1},
1527 { 0x00528604, 1},
1528 { 0x00528680, 1},
1529 { 0x00528714, 1},
1530 { 0x0052881c, 1},
1531 { 0x00528884, 1},
1532 { 0x005288b0, 1},
1533 { 0x005288c8, 2},
1534 { 0x00528b04, 1},
1535 { 0x00528c04, 1},
1536 { 0x00528c10, 8},
1537 { 0x00528c88, 1},
1538 { 0x00528d00, 1},
1539 { 0x00528e08, 1},
1540 { 0x00528f08, 1},
1541 { 0x00529000, 1},
1542 { 0x0052900c, 1},
1543 { 0x00529018, 1},
1544 { 0x00529854, 1},
1545 { 0x00529ab0, 1},
1546 { 0x00529ab8, 3},
1547 { 0x00529c0c, 1},
1548 { 0x00529c8c, 2},
1549 { 0x00529d00, 1},
1550 { 0x00529d08, 2},
1551 { 0x00529e00, 11},
1552 { 0x00529e34, 2},
1553 { 0x00529e44, 11},
1554 { 0x00529e74, 10},
1555 { 0x00529ea4, 1},
1556 { 0x00529eac, 2},
1557 { 0x00529ee8, 1},
1558 { 0x00529ef0, 28},
1559 { 0x00529f70, 1},
1560 { 0x00529f78, 2},
1561 { 0x00529f98, 2},
1562 { 0x00529fdc, 1},
1563 { 0x0052a02c, 2},
1564 { 0x0052a0a0, 1},
1565 { 0x0052a0a8, 1},
1566 { 0x0052a890, 2},
1567 { 0x0052a8a0, 3},
1568 { 0x0052a8b0, 2},
1569 { 0x0052b014, 1},
1570 { 0x0052b0cc, 1},
1571 { 0x0052b1dc, 1},
1572 { 0x0052b214, 1},
1573 { 0x0052b2cc, 1},
1574 { 0x0052b3dc, 1},
1575 { 0x0052b414, 1},
1576 { 0x0052b4cc, 1},
1577 { 0x0052b5dc, 1},
1578 { 0x0052be14, 1},
1579 { 0x0052becc, 1},
1580 { 0x0052bfdc, 1},
1581 { 0x0052c054, 1},
1582 { 0x0052c2b0, 1},
1583 { 0x0052c2b8, 3},
1584 { 0x0052c40c, 1},
1585 { 0x0052c48c, 2},
1586 { 0x0052c500, 1},
1587 { 0x0052c508, 2},
1588 { 0x0052c600, 11},
1589 { 0x0052c634, 2},
1590 { 0x0052c644, 11},
1591 { 0x0052c674, 10},
1592 { 0x0052c6a4, 1},
1593 { 0x0052c6ac, 2},
1594 { 0x0052c6e8, 1},
1595 { 0x0052c6f0, 28},
1596 { 0x0052c770, 1},
1597 { 0x0052c778, 2},
1598 { 0x0052c798, 2},
1599 { 0x0052c7dc, 1},
1600 { 0x0052c854, 1},
1601 { 0x0052cab0, 1},
1602 { 0x0052cab8, 3},
1603 { 0x0052cc0c, 1},
1604 { 0x0052cc8c, 2},
1605 { 0x0052cd00, 1},
1606 { 0x0052cd08, 2},
1607 { 0x0052ce00, 11},
1608 { 0x0052ce34, 2},
1609 { 0x0052ce44, 11},
1610 { 0x0052ce74, 10},
1611 { 0x0052cea4, 1},
1612 { 0x0052ceac, 2},
1613 { 0x0052cee8, 1},
1614 { 0x0052cef0, 28},
1615 { 0x0052cf70, 1},
1616 { 0x0052cf78, 2},
1617 { 0x0052cf98, 2},
1618 { 0x0052cfdc, 1},
1619 { 0x0052d054, 1},
1620 { 0x0052d2b0, 1},
1621 { 0x0052d2b8, 3},
1622 { 0x0052d40c, 1},
1623 { 0x0052d48c, 2},
1624 { 0x0052d500, 1},
1625 { 0x0052d508, 2},
1626 { 0x0052d600, 11},
1627 { 0x0052d634, 2},
1628 { 0x0052d644, 11},
1629 { 0x0052d674, 10},
1630 { 0x0052d6a4, 1},
1631 { 0x0052d6ac, 2},
1632 { 0x0052d6e8, 1},
1633 { 0x0052d6f0, 28},
1634 { 0x0052d770, 1},
1635 { 0x0052d778, 2},
1636 { 0x0052d798, 2},
1637 { 0x0052d7dc, 1},
1638 { 0x0052d854, 1},
1639 { 0x0052dab0, 1},
1640 { 0x0052dab8, 3},
1641 { 0x0052dc0c, 1},
1642 { 0x0052dc8c, 2},
1643 { 0x0052dd00, 1},
1644 { 0x0052dd08, 2},
1645 { 0x0052de00, 11},
1646 { 0x0052de34, 2},
1647 { 0x0052de44, 11},
1648 { 0x0052de74, 10},
1649 { 0x0052dea4, 1},
1650 { 0x0052deac, 2},
1651 { 0x0052dee8, 1},
1652 { 0x0052def0, 28},
1653 { 0x0052df70, 1},
1654 { 0x0052df78, 2},
1655 { 0x0052df98, 2},
1656 { 0x0052dfdc, 1},
1657 { 0x0052e054, 1},
1658 { 0x0052e2b0, 1},
1659 { 0x0052e2b8, 3},
1660 { 0x0052e40c, 1},
1661 { 0x0052e48c, 2},
1662 { 0x0052e500, 1},
1663 { 0x0052e508, 2},
1664 { 0x0052e600, 11},
1665 { 0x0052e634, 2},
1666 { 0x0052e644, 11},
1667 { 0x0052e674, 10},
1668 { 0x0052e6a4, 1},
1669 { 0x0052e6ac, 2},
1670 { 0x0052e6e8, 1},
1671 { 0x0052e6f0, 28},
1672 { 0x0052e770, 1},
1673 { 0x0052e778, 2},
1674 { 0x0052e798, 2},
1675 { 0x0052e7dc, 1},
1676 { 0x00900100, 1},
1677 { 0x00904100, 1},
1678 { 0x00908100, 1},
1679 { 0x0090c100, 1},
1680 { 0x00910100, 1},
1681 { 0x00914100, 1},
1682 { 0x009a0100, 1},
1683};
1684
1685
1686static const u32 gp106_global_whitelist_ranges_count =
1687 ARRAY_SIZE(gp106_global_whitelist_ranges);
1688
1689/* context */
1690
1691/* runcontrol */
1692static const u32 gp106_runcontrol_whitelist[] = {
1693};
1694static const u32 gp106_runcontrol_whitelist_count =
1695 ARRAY_SIZE(gp106_runcontrol_whitelist);
1696
1697static const struct regop_offset_range gp106_runcontrol_whitelist_ranges[] = {
1698};
1699static const u32 gp106_runcontrol_whitelist_ranges_count =
1700 ARRAY_SIZE(gp106_runcontrol_whitelist_ranges);
1701
1702
1703/* quad ctl */
1704static const u32 gp106_qctl_whitelist[] = {
1705};
1706static const u32 gp106_qctl_whitelist_count =
1707 ARRAY_SIZE(gp106_qctl_whitelist);
1708
1709static const struct regop_offset_range gp106_qctl_whitelist_ranges[] = {
1710};
1711static const u32 gp106_qctl_whitelist_ranges_count =
1712 ARRAY_SIZE(gp106_qctl_whitelist_ranges);
1713
1714static const struct regop_offset_range *gp106_get_global_whitelist_ranges(void)
1715{
1716 return gp106_global_whitelist_ranges;
1717}
1718
1719static int gp106_get_global_whitelist_ranges_count(void)
1720{
1721 return gp106_global_whitelist_ranges_count;
1722}
1723
1724static const struct regop_offset_range *gp106_get_context_whitelist_ranges(void)
1725{
1726 return gp106_global_whitelist_ranges;
1727}
1728
1729static int gp106_get_context_whitelist_ranges_count(void)
1730{
1731 return gp106_global_whitelist_ranges_count;
1732}
1733
1734static const u32 *gp106_get_runcontrol_whitelist(void)
1735{
1736 return gp106_runcontrol_whitelist;
1737}
1738
1739static int gp106_get_runcontrol_whitelist_count(void)
1740{
1741 return gp106_runcontrol_whitelist_count;
1742}
1743
1744static const
1745struct regop_offset_range *gp106_get_runcontrol_whitelist_ranges(void)
1746{
1747 return gp106_runcontrol_whitelist_ranges;
1748}
1749
1750static int gp106_get_runcontrol_whitelist_ranges_count(void)
1751{
1752 return gp106_runcontrol_whitelist_ranges_count;
1753}
1754
1755static const u32 *gp106_get_qctl_whitelist(void)
1756{
1757 return gp106_qctl_whitelist;
1758}
1759
1760static int gp106_get_qctl_whitelist_count(void)
1761{
1762 return gp106_qctl_whitelist_count;
1763}
1764
1765static const struct regop_offset_range *gp106_get_qctl_whitelist_ranges(void)
1766{
1767 return gp106_qctl_whitelist_ranges;
1768}
1769
1770static int gp106_get_qctl_whitelist_ranges_count(void)
1771{
1772 return gp106_qctl_whitelist_ranges_count;
1773}
1774
1775static int gp106_apply_smpc_war(struct dbg_session_gk20a *dbg_s)
1776{
1777 /* Not needed on gp106 */
1778 return 0;
1779}
1780
1781void gp106_init_regops(struct gpu_ops *gops)
1782{
1783 gops->regops.get_global_whitelist_ranges =
1784 gp106_get_global_whitelist_ranges;
1785 gops->regops.get_global_whitelist_ranges_count =
1786 gp106_get_global_whitelist_ranges_count;
1787
1788 gops->regops.get_context_whitelist_ranges =
1789 gp106_get_context_whitelist_ranges;
1790 gops->regops.get_context_whitelist_ranges_count =
1791 gp106_get_context_whitelist_ranges_count;
1792
1793 gops->regops.get_runcontrol_whitelist =
1794 gp106_get_runcontrol_whitelist;
1795 gops->regops.get_runcontrol_whitelist_count =
1796 gp106_get_runcontrol_whitelist_count;
1797
1798 gops->regops.get_runcontrol_whitelist_ranges =
1799 gp106_get_runcontrol_whitelist_ranges;
1800 gops->regops.get_runcontrol_whitelist_ranges_count =
1801 gp106_get_runcontrol_whitelist_ranges_count;
1802
1803 gops->regops.get_qctl_whitelist =
1804 gp106_get_qctl_whitelist;
1805 gops->regops.get_qctl_whitelist_count =
1806 gp106_get_qctl_whitelist_count;
1807
1808 gops->regops.get_qctl_whitelist_ranges =
1809 gp106_get_qctl_whitelist_ranges;
1810 gops->regops.get_qctl_whitelist_ranges_count =
1811 gp106_get_qctl_whitelist_ranges_count;
1812
1813 gops->regops.apply_smpc_war =
1814 gp106_apply_smpc_war;
1815}
diff --git a/drivers/gpu/nvgpu/gp106/regops_gp106.h b/drivers/gpu/nvgpu/gp106/regops_gp106.h
new file mode 100644
index 00000000..7f6b6861
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/regops_gp106.h
@@ -0,0 +1,24 @@
1/*
2 *
3 * Tegra GP106 GPU Debugger Driver Register Ops
4 *
5 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef __REGOPS_GP106_H_
20#define __REGOPS_GP106_H_
21
22void gp106_init_regops(struct gpu_ops *gops);
23
24#endif /* __REGOPS_GP106_H_ */
diff --git a/drivers/gpu/nvgpu/gp106/sec2_gp106.c b/drivers/gpu/nvgpu/gp106/sec2_gp106.c
new file mode 100644
index 00000000..8f34edd1
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/sec2_gp106.c
@@ -0,0 +1,388 @@
1/*
2 * Copyright (c) 2016, 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
14#include <linux/delay.h> /* for udelay */
15#include <linux/clk.h>
16#include "gk20a/gk20a.h"
17#include "gk20a/pmu_gk20a.h"
18
19#include "gm206/pmu_gm206.h"
20#include "gm20b/pmu_gm20b.h"
21#include "gp10b/pmu_gp10b.h"
22#include "gp106/pmu_gp106.h"
23#include "gp106/acr_gp106.h"
24#include "gp106/hw_mc_gp106.h"
25#include "gp106/hw_pwr_gp106.h"
26#include "gp106/hw_psec_gp106.h"
27#include "sec2_gp106.h"
28#include "acr.h"
29
30/*Defines*/
31#define gm20b_dbg_pmu(fmt, arg...) \
32 gk20a_dbg(gpu_dbg_pmu, fmt, ##arg)
33
34int sec2_clear_halt_interrupt_status(struct gk20a *g, unsigned int timeout)
35{
36 u32 data = 0;
37 unsigned long end_jiffies = jiffies + msecs_to_jiffies(timeout);
38
39 while (time_before(jiffies, end_jiffies) ||
40 !tegra_platform_is_silicon()) {
41 gk20a_writel(g, psec_falcon_irqsclr_r(),
42 gk20a_readl(g, psec_falcon_irqsclr_r()) | (0x10));
43 data = gk20a_readl(g, psec_falcon_irqstat_r());
44 if ((data & psec_falcon_irqstat_halt_true_f()) !=
45 psec_falcon_irqstat_halt_true_f())
46 /*halt irq is clear*/
47 break;
48 timeout--;
49 udelay(1);
50 }
51 if (timeout == 0)
52 return -EBUSY;
53 return 0;
54}
55
56int sec2_wait_for_halt(struct gk20a *g, unsigned int timeout)
57{
58 u32 data = 0;
59 int completion = -EBUSY;
60 unsigned long end_jiffies = jiffies + msecs_to_jiffies(timeout);
61
62 while (time_before(jiffies, end_jiffies) ||
63 !tegra_platform_is_silicon()) {
64 data = gk20a_readl(g, psec_falcon_cpuctl_r());
65 if (data & psec_falcon_cpuctl_halt_intr_m()) {
66 /*CPU is halted break*/
67 completion = 0;
68 break;
69 }
70 udelay(1);
71 }
72 if (completion){
73 gk20a_err(dev_from_gk20a(g), "ACR boot timed out");
74 }
75 else {
76
77 g->acr.capabilities = gk20a_readl(g, psec_falcon_mailbox1_r());
78 gm20b_dbg_pmu("ACR capabilities %x\n", g->acr.capabilities);
79 data = gk20a_readl(g, psec_falcon_mailbox0_r());
80 if (data) {
81
82 gk20a_err(dev_from_gk20a(g),
83 "ACR boot failed, err %x", data);
84 completion = -EAGAIN;
85 }
86 }
87
88 init_pmu_setup_hw1(g);
89
90 return completion;
91}
92
93void sec2_copy_to_dmem(struct pmu_gk20a *pmu,
94 u32 dst, u8 *src, u32 size, u8 port)
95{
96 struct gk20a *g = gk20a_from_pmu(pmu);
97 u32 i, words, bytes;
98 u32 data, addr_mask;
99 u32 *src_u32 = (u32*)src;
100
101 if (size == 0) {
102 gk20a_err(dev_from_gk20a(g),
103 "size is zero");
104 return;
105 }
106
107 if (dst & 0x3) {
108 gk20a_err(dev_from_gk20a(g),
109 "dst (0x%08x) not 4-byte aligned", dst);
110 return;
111 }
112
113 mutex_lock(&pmu->pmu_copy_lock);
114
115 words = size >> 2;
116 bytes = size & 0x3;
117
118 addr_mask = psec_falcon_dmemc_offs_m() |
119 psec_falcon_dmemc_blk_m();
120
121 dst &= addr_mask;
122
123 gk20a_writel(g, psec_falcon_dmemc_r(port),
124 dst | psec_falcon_dmemc_aincw_f(1));
125
126 for (i = 0; i < words; i++)
127 gk20a_writel(g, psec_falcon_dmemd_r(port), src_u32[i]);
128
129 if (bytes > 0) {
130 data = 0;
131 for (i = 0; i < bytes; i++)
132 ((u8 *)&data)[i] = src[(words << 2) + i];
133 gk20a_writel(g, psec_falcon_dmemd_r(port), data);
134 }
135
136 data = gk20a_readl(g, psec_falcon_dmemc_r(port)) & addr_mask;
137 size = ALIGN(size, 4);
138 if (data != dst + size) {
139 gk20a_err(dev_from_gk20a(g),
140 "copy failed. bytes written %d, expected %d",
141 data - dst, size);
142 }
143 mutex_unlock(&pmu->pmu_copy_lock);
144 return;
145}
146
147int bl_bootstrap_sec2(struct pmu_gk20a *pmu,
148 void *desc, u32 bl_sz)
149{
150 struct gk20a *g = gk20a_from_pmu(pmu);
151 struct acr_desc *acr = &g->acr;
152 struct mm_gk20a *mm = &g->mm;
153 u32 imem_dst_blk = 0;
154 u32 virt_addr = 0;
155 u32 tag = 0;
156 u32 index = 0;
157 struct hsflcn_bl_desc *pmu_bl_gm10x_desc = g->acr.pmu_hsbl_desc;
158 u32 *bl_ucode;
159 u32 data = 0;
160
161 gk20a_dbg_fn("");
162
163 /* SEC2 Config */
164 gk20a_writel(g, psec_falcon_itfen_r(),
165 gk20a_readl(g, psec_falcon_itfen_r()) |
166 psec_falcon_itfen_ctxen_enable_f());
167
168 gk20a_writel(g, psec_falcon_nxtctx_r(),
169 pwr_pmu_new_instblk_ptr_f(
170 gk20a_mm_inst_block_addr(g, &mm->pmu.inst_block) >> 12) |
171 pwr_pmu_new_instblk_valid_f(1) |
172 gk20a_aperture_mask(g, &mm->pmu.inst_block,
173 pwr_pmu_new_instblk_target_sys_coh_f(),
174 pwr_pmu_new_instblk_target_fb_f()));
175
176 data = gk20a_readl(g, psec_falcon_debug1_r());
177 data |= psec_falcon_debug1_ctxsw_mode_m();
178 gk20a_writel(g, psec_falcon_debug1_r(), data);
179
180 data = gk20a_readl(g, psec_falcon_engctl_r());
181 data |= (1 << 3);
182 gk20a_writel(g, psec_falcon_engctl_r(), data);
183
184 /* TBD: load all other surfaces */
185 /*copy bootloader interface structure to dmem*/
186 gk20a_writel(g, psec_falcon_dmemc_r(0),
187 psec_falcon_dmemc_offs_f(0) |
188 psec_falcon_dmemc_blk_f(0) |
189 psec_falcon_dmemc_aincw_f(1));
190 sec2_copy_to_dmem(pmu, 0, (u8 *)desc,
191 sizeof(struct flcn_bl_dmem_desc), 0);
192 /*TODO This had to be copied to bl_desc_dmem_load_off, but since
193 * this is 0, so ok for now*/
194
195 /* Now copy bootloader to TOP of IMEM */
196 imem_dst_blk = (psec_falcon_hwcfg_imem_size_v(
197 gk20a_readl(g, psec_falcon_hwcfg_r()))) - bl_sz/256;
198
199 /* Set Auto-Increment on write */
200 gk20a_writel(g, psec_falcon_imemc_r(0),
201 psec_falcon_imemc_offs_f(0) |
202 psec_falcon_imemc_blk_f(imem_dst_blk) |
203 psec_falcon_imemc_aincw_f(1));
204 virt_addr = pmu_bl_gm10x_desc->bl_start_tag << 8;
205 tag = virt_addr >> 8; /* tag is always 256B aligned */
206 bl_ucode = (u32 *)(acr->hsbl_ucode.cpu_va);
207 for (index = 0; index < bl_sz/4; index++) {
208 if ((index % 64) == 0) {
209 gk20a_writel(g, psec_falcon_imemt_r(0),
210 (tag & 0xffff) << 0);
211 tag++;
212 }
213 gk20a_writel(g, psec_falcon_imemd_r(0),
214 bl_ucode[index] & 0xffffffff);
215 }
216 gk20a_writel(g, psec_falcon_imemt_r(0), (0 & 0xffff) << 0);
217
218 gm20b_dbg_pmu("Before starting falcon with BL\n");
219
220 gk20a_writel(g, psec_falcon_mailbox0_r(), 0xDEADA5A5);
221
222 gk20a_writel(g, psec_falcon_bootvec_r(),
223 psec_falcon_bootvec_vec_f(virt_addr));
224
225 gk20a_writel(g, psec_falcon_cpuctl_r(),
226 psec_falcon_cpuctl_startcpu_f(1));
227
228 return 0;
229}
230
231void sec_enable_irq(struct pmu_gk20a *pmu, bool enable)
232{
233 struct gk20a *g = gk20a_from_pmu(pmu);
234
235 gk20a_dbg_fn("");
236
237 gk20a_writel(g, psec_falcon_irqmclr_r(),
238 psec_falcon_irqmclr_gptmr_f(1) |
239 psec_falcon_irqmclr_wdtmr_f(1) |
240 psec_falcon_irqmclr_mthd_f(1) |
241 psec_falcon_irqmclr_ctxsw_f(1) |
242 psec_falcon_irqmclr_halt_f(1) |
243 psec_falcon_irqmclr_exterr_f(1) |
244 psec_falcon_irqmclr_swgen0_f(1) |
245 psec_falcon_irqmclr_swgen1_f(1) |
246 psec_falcon_irqmclr_ext_f(0xff));
247
248 if (enable) {
249 /* dest 0=falcon, 1=host; level 0=irq0, 1=irq1 */
250 gk20a_writel(g, psec_falcon_irqdest_r(),
251 psec_falcon_irqdest_host_gptmr_f(0) |
252 psec_falcon_irqdest_host_wdtmr_f(1) |
253 psec_falcon_irqdest_host_mthd_f(0) |
254 psec_falcon_irqdest_host_ctxsw_f(0) |
255 psec_falcon_irqdest_host_halt_f(1) |
256 psec_falcon_irqdest_host_exterr_f(0) |
257 psec_falcon_irqdest_host_swgen0_f(1) |
258 psec_falcon_irqdest_host_swgen1_f(0) |
259 psec_falcon_irqdest_host_ext_f(0xff) |
260 psec_falcon_irqdest_target_gptmr_f(1) |
261 psec_falcon_irqdest_target_wdtmr_f(0) |
262 psec_falcon_irqdest_target_mthd_f(0) |
263 psec_falcon_irqdest_target_ctxsw_f(0) |
264 psec_falcon_irqdest_target_halt_f(0) |
265 psec_falcon_irqdest_target_exterr_f(0) |
266 psec_falcon_irqdest_target_swgen0_f(0) |
267 psec_falcon_irqdest_target_swgen1_f(1) |
268 psec_falcon_irqdest_target_ext_f(0xff));
269
270 /* 0=disable, 1=enable */
271 gk20a_writel(g, psec_falcon_irqmset_r(),
272 psec_falcon_irqmset_gptmr_f(1) |
273 psec_falcon_irqmset_wdtmr_f(1) |
274 psec_falcon_irqmset_mthd_f(0) |
275 psec_falcon_irqmset_ctxsw_f(0) |
276 psec_falcon_irqmset_halt_f(1) |
277 psec_falcon_irqmset_exterr_f(1) |
278 psec_falcon_irqmset_swgen0_f(1) |
279 psec_falcon_irqmset_swgen1_f(1));
280
281 }
282
283 gk20a_dbg_fn("done");
284}
285
286void init_pmu_setup_hw1(struct gk20a *g)
287{
288 struct mm_gk20a *mm = &g->mm;
289 struct pmu_gk20a *pmu = &g->pmu;
290 struct gk20a_platform *platform = dev_get_drvdata(g->dev);
291
292 /* PMU TRANSCFG */
293 /* setup apertures - virtual */
294 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_UCODE),
295 pwr_fbif_transcfg_mem_type_physical_f() |
296 pwr_fbif_transcfg_target_local_fb_f());
297 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_VIRT),
298 pwr_fbif_transcfg_mem_type_virtual_f());
299 /* setup apertures - physical */
300 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_PHYS_VID),
301 pwr_fbif_transcfg_mem_type_physical_f() |
302 pwr_fbif_transcfg_target_local_fb_f());
303 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_PHYS_SYS_COH),
304 pwr_fbif_transcfg_mem_type_physical_f() |
305 pwr_fbif_transcfg_target_coherent_sysmem_f());
306 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_PHYS_SYS_NCOH),
307 pwr_fbif_transcfg_mem_type_physical_f() |
308 pwr_fbif_transcfg_target_noncoherent_sysmem_f());
309
310 /* PMU Config */
311 gk20a_writel(g, pwr_falcon_itfen_r(),
312 gk20a_readl(g, pwr_falcon_itfen_r()) |
313 pwr_falcon_itfen_ctxen_enable_f());
314 gk20a_writel(g, pwr_pmu_new_instblk_r(),
315 pwr_pmu_new_instblk_ptr_f(
316 gk20a_mm_inst_block_addr(g, &mm->pmu.inst_block) >> 12) |
317 pwr_pmu_new_instblk_valid_f(1) |
318 gk20a_aperture_mask(g, &mm->pmu.inst_block,
319 pwr_pmu_new_instblk_target_sys_coh_f(),
320 pwr_pmu_new_instblk_target_fb_f()));
321
322 /*Copying pmu cmdline args*/
323 g->ops.pmu_ver.set_pmu_cmdline_args_cpu_freq(pmu,
324 clk_get_rate(platform->clk[1]));
325 g->ops.pmu_ver.set_pmu_cmdline_args_secure_mode(pmu, 1);
326 g->ops.pmu_ver.set_pmu_cmdline_args_trace_size(
327 pmu, GK20A_PMU_TRACE_BUFSIZE);
328 g->ops.pmu_ver.set_pmu_cmdline_args_trace_dma_base(pmu);
329 g->ops.pmu_ver.set_pmu_cmdline_args_trace_dma_idx(
330 pmu, GK20A_PMU_DMAIDX_VIRT);
331
332 pmu_copy_to_dmem(pmu, g->acr.pmu_args,
333 (u8 *)(g->ops.pmu_ver.get_pmu_cmdline_args_ptr(pmu)),
334 g->ops.pmu_ver.get_pmu_cmdline_args_size(pmu), 0);
335
336}
337
338int init_sec2_setup_hw1(struct gk20a *g,
339 void *desc, u32 bl_sz)
340{
341 struct pmu_gk20a *pmu = &g->pmu;
342 int err;
343 u32 data = 0;
344
345 gk20a_dbg_fn("");
346
347 mutex_lock(&pmu->isr_mutex);
348 g->ops.pmu.reset(g);
349 pmu->isr_enabled = true;
350 mutex_unlock(&pmu->isr_mutex);
351
352 data = gk20a_readl(g, psec_fbif_ctl_r());
353 data |= psec_fbif_ctl_allow_phys_no_ctx_allow_f();
354 gk20a_writel(g, psec_fbif_ctl_r(), data);
355
356 data = gk20a_readl(g, psec_falcon_dmactl_r());
357 data &= ~(psec_falcon_dmactl_require_ctx_f(1));
358 gk20a_writel(g, psec_falcon_dmactl_r(), data);
359
360 /* setup apertures - virtual */
361 gk20a_writel(g, psec_fbif_transcfg_r(GK20A_PMU_DMAIDX_UCODE),
362 psec_fbif_transcfg_mem_type_physical_f() |
363 psec_fbif_transcfg_target_local_fb_f());
364 gk20a_writel(g, psec_fbif_transcfg_r(GK20A_PMU_DMAIDX_VIRT),
365 psec_fbif_transcfg_mem_type_virtual_f());
366 /* setup apertures - physical */
367 gk20a_writel(g, psec_fbif_transcfg_r(GK20A_PMU_DMAIDX_PHYS_VID),
368 psec_fbif_transcfg_mem_type_physical_f() |
369 psec_fbif_transcfg_target_local_fb_f());
370 gk20a_writel(g, psec_fbif_transcfg_r(GK20A_PMU_DMAIDX_PHYS_SYS_COH),
371 psec_fbif_transcfg_mem_type_physical_f() |
372 psec_fbif_transcfg_target_coherent_sysmem_f());
373 gk20a_writel(g, psec_fbif_transcfg_r(GK20A_PMU_DMAIDX_PHYS_SYS_NCOH),
374 psec_fbif_transcfg_mem_type_physical_f() |
375 psec_fbif_transcfg_target_noncoherent_sysmem_f());
376
377 /*disable irqs for hs falcon booting as we will poll for halt*/
378 mutex_lock(&pmu->isr_mutex);
379 pmu_enable_irq(pmu, false);
380 sec_enable_irq(pmu, false);
381 pmu->isr_enabled = false;
382 mutex_unlock(&pmu->isr_mutex);
383 err = bl_bootstrap_sec2(pmu, desc, bl_sz);
384 if (err)
385 return err;
386
387 return 0;
388}
diff --git a/drivers/gpu/nvgpu/gp106/sec2_gp106.h b/drivers/gpu/nvgpu/gp106/sec2_gp106.h
new file mode 100644
index 00000000..336bb0f0
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/sec2_gp106.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (c) 2016, 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
14#ifndef __SEC2_H_
15#define __SEC2_H_
16
17int sec2_clear_halt_interrupt_status(struct gk20a *g, unsigned int timeout);
18int sec2_wait_for_halt(struct gk20a *g, unsigned int timeout);
19void sec2_copy_to_dmem(struct pmu_gk20a *pmu,
20 u32 dst, u8 *src, u32 size, u8 port);
21void sec2_dump_falcon_stats(struct pmu_gk20a *pmu);
22int bl_bootstrap_sec2(struct pmu_gk20a *pmu,
23 void *desc, u32 bl_sz);
24void sec_enable_irq(struct pmu_gk20a *pmu, bool enable);
25void init_pmu_setup_hw1(struct gk20a *g);
26int init_sec2_setup_hw1(struct gk20a *g,
27 void *desc, u32 bl_sz);
28
29#endif /*__SEC2_H_*/
diff --git a/drivers/gpu/nvgpu/gp106/therm_gp106.c b/drivers/gpu/nvgpu/gp106/therm_gp106.c
new file mode 100644
index 00000000..7bdf0b9e
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/therm_gp106.c
@@ -0,0 +1,128 @@
1/*
2 * Copyright (c) 2016, 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
14#include "therm_gp106.h"
15#include <linux/debugfs.h>
16#include "hw_therm_gp106.h"
17
18static void gp106_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8)
19{
20 *max_24_8 = (0x87 << 8);
21 *min_24_8 = ((-216) << 8);
22}
23
24static int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8)
25{
26 int err = 0;
27 u32 readval;
28
29 readval = gk20a_readl(g, therm_temp_sensor_tsense_r());
30
31 if (!(therm_temp_sensor_tsense_state_v(readval) &
32 therm_temp_sensor_tsense_state_valid_v())) {
33 gk20a_err(dev_from_gk20a(g),
34 "Attempt to read temperature while sensor is OFF!\n");
35 err = -EINVAL;
36 } else if (therm_temp_sensor_tsense_state_v(readval) &
37 therm_temp_sensor_tsense_state_shadow_v()) {
38 gk20a_err(dev_from_gk20a(g),
39 "Reading temperature from SHADOWed sensor!\n");
40 }
41
42 // Convert from F9.5 -> F27.5 -> F24.8.
43 readval &= therm_temp_sensor_tsense_fixed_point_m();
44
45 *temp_f24_8 = readval;
46
47 return err;
48}
49
50#ifdef CONFIG_DEBUG_FS
51static int therm_get_internal_sensor_curr_temp(void *data, u64 *val)
52{
53 struct gk20a *g = (struct gk20a *)data;
54 u32 readval;
55 int err;
56
57 err = gp106_get_internal_sensor_curr_temp(g, &readval);
58 if (!err)
59 *val = readval;
60
61 return err;
62}
63DEFINE_SIMPLE_ATTRIBUTE(therm_ctrl_fops, therm_get_internal_sensor_curr_temp, NULL, "%llu\n");
64
65static void gp106_therm_debugfs_init(struct gk20a *g) {
66 struct gk20a_platform *platform = dev_get_drvdata(g->dev);
67 struct dentry *dbgentry;
68
69 dbgentry = debugfs_create_file(
70 "temp", S_IRUGO, platform->debugfs, g, &therm_ctrl_fops);
71 if (!dbgentry)
72 gk20a_err(dev_from_gk20a(g), "debugfs entry create failed for therm_curr_temp");
73}
74#endif
75
76static int gp106_elcg_init_idle_filters(struct gk20a *g)
77{
78 u32 gate_ctrl, idle_filter;
79 u32 engine_id;
80 u32 active_engine_id = 0;
81 struct fifo_gk20a *f = &g->fifo;
82
83 gk20a_dbg_fn("");
84
85 for (engine_id = 0; engine_id < f->num_engines; engine_id++) {
86 active_engine_id = f->active_engines_list[engine_id];
87 gate_ctrl = gk20a_readl(g, therm_gate_ctrl_r(active_engine_id));
88
89 if (tegra_platform_is_linsim()) {
90 gate_ctrl = set_field(gate_ctrl,
91 therm_gate_ctrl_eng_delay_after_m(),
92 therm_gate_ctrl_eng_delay_after_f(4));
93 }
94
95 gate_ctrl = set_field(gate_ctrl,
96 therm_gate_ctrl_eng_idle_filt_exp_m(),
97 therm_gate_ctrl_eng_idle_filt_exp_f(2));
98 gate_ctrl = set_field(gate_ctrl,
99 therm_gate_ctrl_eng_idle_filt_mant_m(),
100 therm_gate_ctrl_eng_idle_filt_mant_f(1));
101 gate_ctrl = set_field(gate_ctrl,
102 therm_gate_ctrl_eng_delay_before_m(),
103 therm_gate_ctrl_eng_delay_before_f(0));
104 gk20a_writel(g, therm_gate_ctrl_r(active_engine_id), gate_ctrl);
105 }
106
107 /* default fecs_idle_filter to 0 */
108 idle_filter = gk20a_readl(g, therm_fecs_idle_filter_r());
109 idle_filter &= ~therm_fecs_idle_filter_value_m();
110 gk20a_writel(g, therm_fecs_idle_filter_r(), idle_filter);
111 /* default hubmmu_idle_filter to 0 */
112 idle_filter = gk20a_readl(g, therm_hubmmu_idle_filter_r());
113 idle_filter &= ~therm_hubmmu_idle_filter_value_m();
114 gk20a_writel(g, therm_hubmmu_idle_filter_r(), idle_filter);
115
116 gk20a_dbg_fn("done");
117 return 0;
118}
119
120void gp106_init_therm_ops(struct gpu_ops *gops) {
121#ifdef CONFIG_DEBUG_FS
122 gops->therm.therm_debugfs_init = gp106_therm_debugfs_init;
123#endif
124 gops->therm.elcg_init_idle_filters = gp106_elcg_init_idle_filters;
125 gops->therm.get_internal_sensor_curr_temp = gp106_get_internal_sensor_curr_temp;
126 gops->therm.get_internal_sensor_limits =
127 gp106_get_internal_sensor_limits;
128}
diff --git a/drivers/gpu/nvgpu/gp106/therm_gp106.h b/drivers/gpu/nvgpu/gp106/therm_gp106.h
new file mode 100644
index 00000000..6db17c47
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/therm_gp106.h
@@ -0,0 +1,22 @@
1/*
2 * general thermal control structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef NVGPU_THERM_GP106_H
17#define NVGPU_THERM_GP106_H
18
19#include "gk20a/gk20a.h"
20
21void gp106_init_therm_ops(struct gpu_ops *gops);
22#endif
diff --git a/drivers/gpu/nvgpu/gp106/xve_gp106.c b/drivers/gpu/nvgpu/gp106/xve_gp106.c
new file mode 100644
index 00000000..23a02fbd
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/xve_gp106.c
@@ -0,0 +1,623 @@
1/*
2 * Copyright (c) 2016, 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 <linux/delay.h>
18#include <linux/kernel.h>
19#include <linux/debugfs.h>
20
21#include "gk20a/gk20a.h"
22#include "gm206/bios_gm206.h"
23#include "gp106/xve_gp106.h"
24
25#include "gp106/hw_xp_gp106.h"
26#include "gp106/hw_xve_gp106.h"
27
28/**
29 * Init a timer and place the timeout data in @timeout.
30 */
31static void init_timeout(u32 timeout_ms, u32 *timeout)
32{
33 *timeout = jiffies + msecs_to_jiffies(timeout_ms);
34}
35
36/**
37 * Returns 1 if the current time is after @timeout i.e: the timer timed
38 * out. Returns 0 if the timer still has time left.
39 */
40static int check_timeout(u32 *timeout)
41{
42 unsigned long now = jiffies;
43 unsigned long timeout_l = (unsigned long)*timeout;
44
45 if (time_after(now, timeout_l))
46 return 1;
47
48 return 0;
49}
50
51static void xve_xve_writel_gp106(struct gk20a *g, u32 reg, u32 val)
52{
53 gk20a_writel(g, NV_PCFG + reg, val);
54}
55
56static u32 xve_xve_readl_gp106(struct gk20a *g, u32 reg)
57{
58 return gk20a_readl(g, NV_PCFG + reg);
59}
60
61/**
62 * Places one of:
63 *
64 * %GPU_XVE_SPEED_2P5
65 * %GPU_XVE_SPEED_5P0
66 * %GPU_XVE_SPEED_8P0
67 *
68 * in the u32 pointed to by @xve_link_speed. If for some reason an unknown PCIe
69 * bus speed is detected then *@xve_link_speed is not touched and -ENODEV is
70 * returned.
71 */
72static int xve_get_speed_gp106(struct gk20a *g, u32 *xve_link_speed)
73{
74 u32 status;
75 u32 link_speed, real_link_speed = 0;
76
77 status = g->ops.xve.xve_readl(g, xve_link_control_status_r());
78
79 link_speed = xve_link_control_status_link_speed_v(status);
80
81 /*
82 * Can't use a switch statement becuase switch statements dont work with
83 * function calls.
84 */
85 if (link_speed == xve_link_control_status_link_speed_link_speed_2p5_v())
86 real_link_speed = GPU_XVE_SPEED_2P5;
87 if (link_speed == xve_link_control_status_link_speed_link_speed_5p0_v())
88 real_link_speed = GPU_XVE_SPEED_5P0;
89 if (link_speed == xve_link_control_status_link_speed_link_speed_8p0_v())
90 real_link_speed = GPU_XVE_SPEED_8P0;
91
92 if (!real_link_speed) {
93 pr_warn("%s: Unknown PCIe bus speed!\n", __func__);
94 return -ENODEV;
95 }
96
97 *xve_link_speed = real_link_speed;
98 return 0;
99}
100
101/**
102 * Set the mask for L0s in the XVE.
103 *
104 * When @status is non-zero the mask for L0s is set which _disables_ L0s. When
105 * @status is zero L0s is no longer masked and may be enabled.
106 */
107static void set_xve_l0s_mask(struct gk20a *g, bool status)
108{
109 u32 xve_priv;
110 u32 status_bit = status ? 1 : 0;
111
112 xve_priv = g->ops.xve.xve_readl(g, xve_priv_xv_r());
113
114 xve_priv = set_field(xve_priv,
115 xve_priv_xv_cya_l0s_enable_m(),
116 xve_priv_xv_cya_l0s_enable_f(status_bit));
117
118 g->ops.xve.xve_writel(g, xve_priv_xv_r(), xve_priv);
119}
120
121/**
122 * Set the mask for L1 in the XVE.
123 *
124 * When @status is non-zero the mask for L1 is set which _disables_ L0s. When
125 * @status is zero L1 is no longer masked and may be enabled.
126 */
127static void set_xve_l1_mask(struct gk20a *g, int status)
128{
129 u32 xve_priv;
130 u32 status_bit = status ? 1 : 0;
131
132 xve_priv = g->ops.xve.xve_readl(g, xve_priv_xv_r());
133
134 xve_priv = set_field(xve_priv,
135 xve_priv_xv_cya_l1_enable_m(),
136 xve_priv_xv_cya_l1_enable_f(status_bit));
137
138 g->ops.xve.xve_writel(g, xve_priv_xv_r(), xve_priv);
139}
140
141/**
142 * When doing the speed change disable power saving features.
143 */
144static void disable_aspm_gp106(struct gk20a *g)
145{
146 u32 xve_priv;
147
148 xve_priv = g->ops.xve.xve_readl(g, xve_priv_xv_r());
149
150 /*
151 * Store prior ASPM state so we can restore it later on.
152 */
153 g->xve_l0s = xve_priv_xv_cya_l0s_enable_v(xve_priv);
154 g->xve_l1 = xve_priv_xv_cya_l1_enable_v(xve_priv);
155
156 set_xve_l0s_mask(g, true);
157 set_xve_l1_mask(g, true);
158}
159
160/**
161 * Restore the state saved by disable_aspm_gp106().
162 */
163static void enable_aspm_gp106(struct gk20a *g)
164{
165 set_xve_l0s_mask(g, g->xve_l0s);
166 set_xve_l1_mask(g, g->xve_l1);
167}
168
169/*
170 * Error checking is done in xve_set_speed_gp106.
171 */
172static int __do_xve_set_speed_gp106(struct gk20a *g, u32 next_link_speed)
173{
174 u32 current_link_speed, new_link_speed;
175 u32 dl_mgr, saved_dl_mgr;
176 u32 pl_link_config;
177 u32 link_control_status, link_speed_setting, link_width;
178 u32 timeout;
179 int attempts = 10, err_status = 0;
180
181 g->ops.xve.get_speed(g, &current_link_speed);
182 xv_sc_dbg(PRE_CHANGE, "Executing PCIe link change.");
183 xv_sc_dbg(PRE_CHANGE, " Current speed: %s",
184 xve_speed_to_str(current_link_speed));
185 xv_sc_dbg(PRE_CHANGE, " Next speed: %s",
186 xve_speed_to_str(next_link_speed));
187 xv_sc_dbg(PRE_CHANGE, " PL_LINK_CONFIG: 0x%08x",
188 gk20a_readl(g, xp_pl_link_config_r(0)));
189
190 xv_sc_dbg(DISABLE_ASPM, "Disabling ASPM...");
191 disable_aspm_gp106(g);
192 xv_sc_dbg(DISABLE_ASPM, " Done!");
193
194 xv_sc_dbg(DL_SAFE_MODE, "Putting DL in safe mode...");
195 saved_dl_mgr = gk20a_readl(g, xp_dl_mgr_r(0));
196
197 /*
198 * Put the DL in safe mode.
199 */
200 dl_mgr = saved_dl_mgr;
201 dl_mgr |= xp_dl_mgr_safe_timing_f(1);
202 gk20a_writel(g, xp_dl_mgr_r(0), dl_mgr);
203 xv_sc_dbg(DL_SAFE_MODE, " Done!");
204
205 init_timeout(GPU_XVE_TIMEOUT_MS, &timeout);
206
207 xv_sc_dbg(CHECK_LINK, "Checking for link idle...");
208 while (1) {
209 pl_link_config = gk20a_readl(g, xp_pl_link_config_r(0));
210 if ((xp_pl_link_config_ltssm_status_f(pl_link_config) ==
211 xp_pl_link_config_ltssm_status_idle_v()) &&
212 (xp_pl_link_config_ltssm_directive_f(pl_link_config) ==
213 xp_pl_link_config_ltssm_directive_normal_operations_v()))
214 break;
215
216 if (check_timeout(&timeout)) {
217 err_status = -ETIMEDOUT;
218 break;
219 }
220 }
221
222 if (err_status == -ETIMEDOUT)
223 /* TODO: debug message. */
224 goto done;
225
226 xv_sc_dbg(CHECK_LINK, " Done");
227
228 xv_sc_dbg(LINK_SETTINGS, "Preparing next link settings");
229 pl_link_config &= ~xp_pl_link_config_max_link_rate_m();
230 switch (next_link_speed) {
231 case GPU_XVE_SPEED_2P5:
232 link_speed_setting =
233 xve_link_control_status_link_speed_link_speed_2p5_v();
234 pl_link_config |= xp_pl_link_config_max_link_rate_f(
235 xp_pl_link_config_max_link_rate_2500_mtps_v());
236 break;
237 case GPU_XVE_SPEED_5P0:
238 link_speed_setting =
239 xve_link_control_status_link_speed_link_speed_5p0_v();
240 pl_link_config |= xp_pl_link_config_max_link_rate_f(
241 xp_pl_link_config_max_link_rate_5000_mtps_v());
242 break;
243 case GPU_XVE_SPEED_8P0:
244 link_speed_setting =
245 xve_link_control_status_link_speed_link_speed_8p0_v();
246 pl_link_config |= xp_pl_link_config_max_link_rate_f(
247 xp_pl_link_config_max_link_rate_8000_mtps_v());
248 break;
249 default:
250 BUG(); /* Should never be hit. */
251 }
252
253 link_control_status =
254 g->ops.xve.xve_readl(g, xve_link_control_status_r());
255 link_width = xve_link_control_status_link_width_v(link_control_status);
256
257 pl_link_config &= ~xp_pl_link_config_target_tx_width_m();
258
259 /* Can't use a switch due to oddities in register definitions. */
260 if (link_width == xve_link_control_status_link_width_x1_v())
261 pl_link_config |= xp_pl_link_config_target_tx_width_f(
262 xp_pl_link_config_target_tx_width_x1_v());
263 else if (link_width == xve_link_control_status_link_width_x2_v())
264 pl_link_config |= xp_pl_link_config_target_tx_width_f(
265 xp_pl_link_config_target_tx_width_x2_v());
266 else if (link_width == xve_link_control_status_link_width_x4_v())
267 pl_link_config |= xp_pl_link_config_target_tx_width_f(
268 xp_pl_link_config_target_tx_width_x4_v());
269 else if (link_width == xve_link_control_status_link_width_x8_v())
270 pl_link_config |= xp_pl_link_config_target_tx_width_f(
271 xp_pl_link_config_target_tx_width_x8_v());
272 else if (link_width == xve_link_control_status_link_width_x16_v())
273 pl_link_config |= xp_pl_link_config_target_tx_width_f(
274 xp_pl_link_config_target_tx_width_x16_v());
275 else
276 BUG();
277
278 xv_sc_dbg(LINK_SETTINGS, " pl_link_config = 0x%08x", pl_link_config);
279 xv_sc_dbg(LINK_SETTINGS, " Done");
280
281 xv_sc_dbg(EXEC_CHANGE, "Running link speed change...");
282
283 init_timeout(GPU_XVE_TIMEOUT_MS, &timeout);
284 while (1) {
285 gk20a_writel(g, xp_pl_link_config_r(0), pl_link_config);
286 if (pl_link_config ==
287 gk20a_readl(g, xp_pl_link_config_r(0)))
288 break;
289
290 if (check_timeout(&timeout)) {
291 err_status = -ETIMEDOUT;
292 break;
293 }
294 }
295
296 if (err_status == -ETIMEDOUT)
297 goto done;
298
299 xv_sc_dbg(EXEC_CHANGE, " Wrote PL_LINK_CONFIG.");
300
301 pl_link_config = gk20a_readl(g, xp_pl_link_config_r(0));
302
303 do {
304 pl_link_config = set_field(pl_link_config,
305 xp_pl_link_config_ltssm_directive_m(),
306 xp_pl_link_config_ltssm_directive_f(
307 xp_pl_link_config_ltssm_directive_change_speed_v()));
308
309 xv_sc_dbg(EXEC_CHANGE, " Executing change (0x%08x)!",
310 pl_link_config);
311 gk20a_writel(g, xp_pl_link_config_r(0), pl_link_config);
312
313 /*
314 * Read NV_XP_PL_LINK_CONFIG until the link has swapped to
315 * the target speed.
316 */
317 init_timeout(GPU_XVE_TIMEOUT_MS, &timeout);
318 while (1) {
319 pl_link_config = gk20a_readl(g, xp_pl_link_config_r(0));
320 if (pl_link_config != 0xfffffff &&
321 (xp_pl_link_config_ltssm_status_f(pl_link_config) ==
322 xp_pl_link_config_ltssm_status_idle_v()) &&
323 (xp_pl_link_config_ltssm_directive_f(pl_link_config) ==
324 xp_pl_link_config_ltssm_directive_normal_operations_v()))
325 break;
326
327 if (check_timeout(&timeout)) {
328 err_status = -ETIMEDOUT;
329 xv_sc_dbg(EXEC_CHANGE, " timeout; pl_link_config = 0x%x",
330 pl_link_config);
331 break;
332 }
333 }
334
335 xv_sc_dbg(EXEC_CHANGE, " Change done... Checking status");
336
337 if (pl_link_config == 0xffffffff) {
338 WARN(1, "GPU fell of PCI bus!?");
339
340 /*
341 * The rest of the driver is probably about to
342 * explode...
343 */
344 BUG();
345 }
346
347 link_control_status =
348 g->ops.xve.xve_readl(g, xve_link_control_status_r());
349 xv_sc_dbg(EXEC_CHANGE, " target %d vs current %d",
350 link_speed_setting,
351 xve_link_control_status_link_speed_v(link_control_status));
352
353 if (err_status == -ETIMEDOUT)
354 xv_sc_dbg(EXEC_CHANGE, " Oops timed out?");
355 } while (attempts-- > 0 &&
356 link_speed_setting !=
357 xve_link_control_status_link_speed_v(link_control_status));
358
359 xv_sc_dbg(EXEC_VERIF, "Verifying speed change...");
360
361 /*
362 * Check that the new link speed is actually active. If we failed to
363 * change to the new link speed then return to the link speed setting
364 * pre-speed change.
365 */
366 new_link_speed = xve_link_control_status_link_speed_v(
367 link_control_status);
368 if (link_speed_setting != new_link_speed) {
369 u32 link_config = gk20a_readl(g, xp_pl_link_config_r(0));
370
371 xv_sc_dbg(EXEC_VERIF, " Current and target speeds mismatch!");
372 xv_sc_dbg(EXEC_VERIF, " LINK_CONTROL_STATUS: 0x%08x",
373 g->ops.xve.xve_readl(g, xve_link_control_status_r()));
374 xv_sc_dbg(EXEC_VERIF, " Link speed is %s - should be %s",
375 xve_speed_to_str(new_link_speed),
376 xve_speed_to_str(link_speed_setting));
377
378 link_config &= ~xp_pl_link_config_max_link_rate_m();
379 if (new_link_speed ==
380 xve_link_control_status_link_speed_link_speed_2p5_v())
381 link_config |= xp_pl_link_config_max_link_rate_f(
382 xp_pl_link_config_max_link_rate_2500_mtps_v());
383 else if (new_link_speed ==
384 xve_link_control_status_link_speed_link_speed_5p0_v())
385 link_config |= xp_pl_link_config_max_link_rate_f(
386 xp_pl_link_config_max_link_rate_5000_mtps_v());
387 else if (new_link_speed ==
388 xve_link_control_status_link_speed_link_speed_8p0_v())
389 link_config |= xp_pl_link_config_max_link_rate_f(
390 xp_pl_link_config_max_link_rate_8000_mtps_v());
391 else
392 link_config |= xp_pl_link_config_max_link_rate_f(
393 xp_pl_link_config_max_link_rate_2500_mtps_v());
394
395 gk20a_writel(g, xp_pl_link_config_r(0), link_config);
396 err_status = -ENODEV;
397 } else {
398 xv_sc_dbg(EXEC_VERIF, " Current and target speeds match!");
399 err_status = 0;
400 }
401
402done:
403 /* Restore safe timings. */
404 xv_sc_dbg(CLEANUP, "Restoring saved DL settings...");
405 gk20a_writel(g, xp_dl_mgr_r(0), saved_dl_mgr);
406 xv_sc_dbg(CLEANUP, " Done");
407
408 xv_sc_dbg(CLEANUP, "Re-enabling ASPM settings...");
409 enable_aspm_gp106(g);
410 xv_sc_dbg(CLEANUP, " Done");
411
412 return err_status;
413}
414
415/**
416 * Sets the PCIe link speed to @xve_link_speed which must be one of:
417 *
418 * %GPU_XVE_SPEED_2P5
419 * %GPU_XVE_SPEED_5P0
420 * %GPU_XVE_SPEED_8P0
421 *
422 * If an error is encountered an appropriate error will be returned.
423 */
424static int xve_set_speed_gp106(struct gk20a *g, u32 next_link_speed)
425{
426 u32 current_link_speed;
427 int err;
428
429 if ((next_link_speed & GPU_XVE_SPEED_MASK) == 0)
430 return -EINVAL;
431
432 err = g->ops.xve.get_speed(g, &current_link_speed);
433 if (err)
434 return err;
435
436 /* No-op. */
437 if (current_link_speed == next_link_speed)
438 return 0;
439
440 return __do_xve_set_speed_gp106(g, next_link_speed);
441}
442
443/**
444 * Places a bitmask of available speeds for gp106 in @speed_mask.
445 */
446static void xve_available_speeds_gp106(struct gk20a *g, u32 *speed_mask)
447{
448 *speed_mask = GPU_XVE_SPEED_2P5 | GPU_XVE_SPEED_5P0;
449}
450
451static ssize_t xve_link_speed_write(struct file *filp,
452 const char __user *buff,
453 size_t len, loff_t *off)
454{
455 struct gk20a *g = ((struct seq_file *)filp->private_data)->private;
456 char kbuff[16];
457 u32 buff_size, check_len;
458 u32 link_speed = 0;
459 int ret;
460
461 buff_size = min_t(size_t, 16, len);
462
463 memset(kbuff, 0, 16);
464 if (copy_from_user(kbuff, buff, buff_size))
465 return -EFAULT;
466
467 check_len = strlen("Gen1");
468 if (strncmp(kbuff, "Gen1", check_len) == 0)
469 link_speed = GPU_XVE_SPEED_2P5;
470 else if (strncmp(kbuff, "Gen2", check_len) == 0)
471 link_speed = GPU_XVE_SPEED_5P0;
472 else if (strncmp(kbuff, "Gen3", check_len) == 0)
473 link_speed = GPU_XVE_SPEED_8P0;
474 else
475 gk20a_err(g->dev, "%s: Unknown PCIe speed: %s\n",
476 __func__, kbuff);
477
478 if (!link_speed)
479 return -EINVAL;
480
481 /* Brief pause... To help rate limit this. */
482 msleep(250);
483
484 /*
485 * And actually set the speed. Yay.
486 */
487 ret = g->ops.xve.set_speed(g, link_speed);
488 if (ret)
489 return ret;
490
491 return len;
492}
493
494static int xve_link_speed_show(struct seq_file *s, void *unused)
495{
496 struct gk20a *g = s->private;
497 u32 speed;
498 int err;
499
500 err = g->ops.xve.get_speed(g, &speed);
501 if (err)
502 return err;
503
504 seq_printf(s, "Current PCIe speed:\n %s\n", xve_speed_to_str(speed));
505
506 return 0;
507}
508
509static int xve_link_speed_open(struct inode *inode, struct file *file)
510{
511 return single_open(file, xve_link_speed_show, inode->i_private);
512}
513
514static const struct file_operations xve_link_speed_fops = {
515 .open = xve_link_speed_open,
516 .read = seq_read,
517 .write = xve_link_speed_write,
518 .llseek = seq_lseek,
519 .release = single_release,
520};
521
522static int xve_available_speeds_show(struct seq_file *s, void *unused)
523{
524 struct gk20a *g = s->private;
525 u32 available_speeds;
526
527 g->ops.xve.available_speeds(g, &available_speeds);
528
529 seq_puts(s, "Available PCIe bus speeds:\n");
530 if (available_speeds & GPU_XVE_SPEED_2P5)
531 seq_puts(s, " Gen1\n");
532 if (available_speeds & GPU_XVE_SPEED_5P0)
533 seq_puts(s, " Gen2\n");
534 if (available_speeds & GPU_XVE_SPEED_8P0)
535 seq_puts(s, " Gen3\n");
536
537 return 0;
538}
539
540static int xve_available_speeds_open(struct inode *inode, struct file *file)
541{
542 return single_open(file, xve_available_speeds_show, inode->i_private);
543}
544
545static const struct file_operations xve_available_speeds_fops = {
546 .open = xve_available_speeds_open,
547 .read = seq_read,
548 .llseek = seq_lseek,
549 .release = single_release,
550};
551
552static int xve_link_control_status_show(struct seq_file *s, void *unused)
553{
554 struct gk20a *g = s->private;
555 u32 link_status;
556
557 link_status = g->ops.xve.xve_readl(g, xve_link_control_status_r());
558 seq_printf(s, "0x%08x\n", link_status);
559
560 return 0;
561}
562
563static int xve_link_control_status_open(struct inode *inode, struct file *file)
564{
565 return single_open(file, xve_link_control_status_show, inode->i_private);
566}
567
568static const struct file_operations xve_link_control_status_fops = {
569 .open = xve_link_control_status_open,
570 .read = seq_read,
571 .llseek = seq_lseek,
572 .release = single_release,
573};
574
575static int xve_sw_init_gp106(struct device *dev)
576{
577 int err = -ENODEV;
578#ifdef CONFIG_DEBUG_FS
579 struct gk20a *g = get_gk20a(dev);
580 struct gk20a_platform *plat = gk20a_get_platform(dev);
581 struct dentry *gpu_root = plat->debugfs;
582
583 g->debugfs_xve = debugfs_create_dir("xve", gpu_root);
584 if (IS_ERR_OR_NULL(g->debugfs_xve))
585 goto fail;
586
587 /*
588 * These are just debug nodes. If they fail to get made it's not worth
589 * worrying the higher level SW.
590 */
591 debugfs_create_file("link_speed", S_IRUGO,
592 g->debugfs_xve, g,
593 &xve_link_speed_fops);
594 debugfs_create_file("available_speeds", S_IRUGO,
595 g->debugfs_xve, g,
596 &xve_available_speeds_fops);
597 debugfs_create_file("link_control_status", S_IRUGO,
598 g->debugfs_xve, g,
599 &xve_link_control_status_fops);
600
601 err = 0;
602fail:
603 return err;
604#else
605 return err;
606#endif
607}
608
609/*
610 * Init the HAL functions and what not. xve_sw_init_gp106() is for initializing
611 * all the other stuff like debugfs nodes, etc.
612 */
613int gp106_init_xve_ops(struct gpu_ops *gops)
614{
615 gops->xve.sw_init = xve_sw_init_gp106;
616 gops->xve.get_speed = xve_get_speed_gp106;
617 gops->xve.set_speed = xve_set_speed_gp106;
618 gops->xve.available_speeds = xve_available_speeds_gp106;
619 gops->xve.xve_readl = xve_xve_readl_gp106;
620 gops->xve.xve_writel = xve_xve_writel_gp106;
621
622 return 0;
623}
diff --git a/drivers/gpu/nvgpu/gp106/xve_gp106.h b/drivers/gpu/nvgpu/gp106/xve_gp106.h
new file mode 100644
index 00000000..65c75bf0
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp106/xve_gp106.h
@@ -0,0 +1,99 @@
1/*
2 * Copyright (c) 2016, 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#ifndef __XVE_GP106_H__
18#define __XVE_GP106_H__
19
20#include "gk20a/gk20a.h"
21
22int gp106_init_xve_ops(struct gpu_ops *gops);
23
24/*
25 * Best guess for a reasonable timeout.
26 */
27#define GPU_XVE_TIMEOUT_MS 500
28
29/*
30 * For the available speeds bitmap.
31 */
32#define GPU_XVE_SPEED_2P5 (1 << 0)
33#define GPU_XVE_SPEED_5P0 (1 << 1)
34#define GPU_XVE_SPEED_8P0 (1 << 2)
35#define GPU_XVE_NR_SPEEDS 3
36
37#define GPU_XVE_SPEED_MASK (GPU_XVE_SPEED_2P5 | \
38 GPU_XVE_SPEED_5P0 | \
39 GPU_XVE_SPEED_8P0)
40
41/*
42 * The HW uses a 2 bit field where speed is defined by a number:
43 *
44 * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_2P5 = 1
45 * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_5P0 = 2
46 * NV_XVE_LINK_CONTROL_STATUS_LINK_SPEED_8P0 = 3
47 *
48 * This isn't ideal for a bitmap with available speeds. So the external
49 * APIs think about speeds as a bit in a bitmap and this function converts
50 * from those bits to the actual HW speed setting.
51 *
52 * @speed_bit must have only 1 bit set and must be one of the 3 available
53 * HW speeds. Not all chips support all speeds so use available_speeds() to
54 * determine what a given chip supports.
55 */
56static inline u32 xve_speed_to_hw_speed_setting(u32 speed_bit)
57{
58 if (!speed_bit ||
59 !is_power_of_2(speed_bit) ||
60 !(speed_bit & GPU_XVE_SPEED_MASK))
61 return -EINVAL;
62
63 return ilog2(speed_bit) + 1;
64}
65
66static inline const char *xve_speed_to_str(u32 speed)
67{
68 if (!speed || !is_power_of_2(speed) ||
69 !(speed & GPU_XVE_SPEED_MASK))
70 return "Unknown ???";
71
72 return speed & GPU_XVE_SPEED_2P5 ? "Gen1" :
73 speed & GPU_XVE_SPEED_5P0 ? "Gen2" :
74 speed & GPU_XVE_SPEED_8P0 ? "Gen3" :
75 "Unknown ???";
76}
77
78/*
79 * Debugging for the speed change.
80 */
81enum xv_speed_change_steps {
82 PRE_CHANGE = 0,
83 DISABLE_ASPM,
84 DL_SAFE_MODE,
85 CHECK_LINK,
86 LINK_SETTINGS,
87 EXEC_CHANGE,
88 EXEC_VERIF,
89 CLEANUP
90};
91
92#define xv_dbg(fmt, args...) \
93 gk20a_dbg(gpu_dbg_xv, fmt, ##args)
94
95#define xv_sc_dbg(step, fmt, args...) \
96 xv_dbg("[%d] %15s | " fmt, step, __stringify(step), ##args)
97
98
99#endif
diff --git a/drivers/gpu/nvgpu/gp10b/cde_gp10b.c b/drivers/gpu/nvgpu/gp10b/cde_gp10b.c
new file mode 100644
index 00000000..4a16abd1
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/cde_gp10b.c
@@ -0,0 +1,148 @@
1/*
2 * GP10B CDE
3 *
4 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include "gk20a/gk20a.h"
17#include "cde_gp10b.h"
18
19enum gp10b_programs {
20 GP10B_PROG_HPASS = 0,
21 GP10B_PROG_HPASS_4K = 1,
22 GP10B_PROG_VPASS = 2,
23 GP10B_PROG_VPASS_4K = 3,
24 GP10B_PROG_HPASS_DEBUG = 4,
25 GP10B_PROG_HPASS_4K_DEBUG = 5,
26 GP10B_PROG_VPASS_DEBUG = 6,
27 GP10B_PROG_VPASS_4K_DEBUG = 7,
28 GP10B_PROG_PASSTHROUGH = 8,
29};
30
31static void gp10b_cde_get_program_numbers(struct gk20a *g,
32 u32 block_height_log2,
33 int *hprog_out, int *vprog_out)
34{
35 int hprog, vprog;
36
37 if (g->cde_app.shader_parameter == 1) {
38 hprog = GP10B_PROG_PASSTHROUGH;
39 vprog = GP10B_PROG_PASSTHROUGH;
40 } else {
41 hprog = GP10B_PROG_HPASS;
42 vprog = GP10B_PROG_VPASS;
43 if (g->cde_app.shader_parameter == 2) {
44 hprog = GP10B_PROG_HPASS_DEBUG;
45 vprog = GP10B_PROG_VPASS_DEBUG;
46 }
47 if (g->mm.bypass_smmu) {
48 if (!g->mm.disable_bigpage) {
49 gk20a_warn(g->dev,
50 "when bypass_smmu is 1, disable_bigpage must be 1 too");
51 }
52 hprog |= 1;
53 vprog |= 1;
54 }
55 }
56
57 *hprog_out = hprog;
58 *vprog_out = vprog;
59}
60
61static bool gp10b_need_scatter_buffer(struct gk20a *g)
62{
63 return g->mm.bypass_smmu;
64}
65
66static u8 parity(u32 a)
67{
68 a ^= a>>16u;
69 a ^= a>>8u;
70 a ^= a>>4u;
71 a &= 0xfu;
72 return (0x6996u >> a) & 1u;
73}
74
75static int gp10b_populate_scatter_buffer(struct gk20a *g,
76 struct sg_table *sgt,
77 size_t surface_size,
78 void *scatter_buffer_ptr,
79 size_t scatter_buffer_size)
80{
81 /* map scatter buffer to CPU VA and fill it */
82 const u32 page_size_log2 = 12;
83 const u32 page_size = 1 << page_size_log2;
84 const u32 page_size_shift = page_size_log2 - 7u;
85
86 /* 0011 1111 1111 1111 1111 1110 0100 1000 */
87 const u32 getSliceMaskGP10B = 0x3ffffe48;
88 u8 *scatter_buffer = scatter_buffer_ptr;
89
90 size_t i;
91 struct scatterlist *sg = NULL;
92 u8 d = 0;
93 size_t page = 0;
94 size_t pages_left;
95
96 surface_size = round_up(surface_size, page_size);
97
98 pages_left = surface_size >> page_size_log2;
99 if ((pages_left >> 3) > scatter_buffer_size)
100 return -ENOMEM;
101
102 for_each_sg(sgt->sgl, sg, sgt->nents, i) {
103 unsigned int j;
104 u64 surf_pa = sg_phys(sg);
105 unsigned int n = (int)(sg->length >> page_size_log2);
106
107 gk20a_dbg(gpu_dbg_cde, "surfPA=0x%llx + %d pages", surf_pa, n);
108
109 for (j=0; j < n && pages_left > 0; j++, surf_pa += page_size) {
110 u32 addr = (((u32)(surf_pa>>7)) & getSliceMaskGP10B) >> page_size_shift;
111 u8 scatter_bit = parity(addr);
112 u8 bit = page & 7;
113
114 d |= scatter_bit << bit;
115 if (bit == 7) {
116 scatter_buffer[page >> 3] = d;
117 d = 0;
118 }
119
120 ++page;
121 --pages_left;
122 }
123
124 if (pages_left == 0)
125 break;
126 }
127
128 /* write the last byte in case the number of pages is not divisible by 8 */
129 if ((page & 7) != 0)
130 scatter_buffer[page >> 3] = d;
131
132#if defined(GK20A_DEBUG)
133 if (unlikely(gpu_dbg_cde & gk20a_dbg_mask)) {
134 gk20a_dbg(gpu_dbg_cde, "scatterBuffer content:");
135 for (i=0; i < page>>3; i++) {
136 gk20a_dbg(gpu_dbg_cde, " %x", scatter_buffer[i]);
137 }
138 }
139#endif
140 return 0;
141}
142
143void gp10b_init_cde_ops(struct gpu_ops *gops)
144{
145 gops->cde.get_program_numbers = gp10b_cde_get_program_numbers;
146 gops->cde.need_scatter_buffer = gp10b_need_scatter_buffer;
147 gops->cde.populate_scatter_buffer = gp10b_populate_scatter_buffer;
148}
diff --git a/drivers/gpu/nvgpu/gp10b/cde_gp10b.h b/drivers/gpu/nvgpu/gp10b/cde_gp10b.h
new file mode 100644
index 00000000..52f785f1
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/cde_gp10b.h
@@ -0,0 +1,23 @@
1/*
2 * GP10B CDE
3 *
4 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _NVHOST_GP10B_CDE
17#define _NVHOST_GP10B_CDE
18
19struct gpu_ops;
20
21void gp10b_init_cde_ops(struct gpu_ops *gops);
22
23#endif
diff --git a/drivers/gpu/nvgpu/gp10b/ce_gp10b.c b/drivers/gpu/nvgpu/gp10b/ce_gp10b.c
new file mode 100644
index 00000000..e5082778
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/ce_gp10b.c
@@ -0,0 +1,82 @@
1/*
2 * Pascal GPU series Copy Engine.
3 *
4 * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program.
17 */
18
19#include "gk20a/gk20a.h" /* FERMI and MAXWELL classes defined here */
20#include "hw_ce_gp10b.h"
21#include "ce_gp10b.h"
22
23static void ce_nonblockpipe_isr(struct gk20a *g, u32 fifo_intr)
24{
25 gk20a_dbg(gpu_dbg_intr, "ce non-blocking pipe interrupt\n");
26
27 /* wake theads waiting in this channel */
28 gk20a_channel_semaphore_wakeup(g, true);
29 return;
30}
31
32static u32 ce_blockpipe_isr(struct gk20a *g, u32 fifo_intr)
33{
34 gk20a_dbg(gpu_dbg_intr, "ce blocking pipe interrupt\n");
35
36 return ce_intr_status_blockpipe_pending_f();
37}
38
39static u32 ce_launcherr_isr(struct gk20a *g, u32 fifo_intr)
40{
41 gk20a_dbg(gpu_dbg_intr, "ce launch error interrupt\n");
42
43 return ce_intr_status_launcherr_pending_f();
44}
45
46static void gp10b_ce_isr(struct gk20a *g, u32 inst_id, u32 pri_base)
47{
48 u32 ce_intr = gk20a_readl(g, ce_intr_status_r(inst_id));
49 u32 clear_intr = 0;
50
51 gk20a_dbg(gpu_dbg_intr, "ce isr %08x %08x\n", ce_intr, inst_id);
52
53 /* clear blocking interrupts: they exibit broken behavior */
54 if (ce_intr & ce_intr_status_blockpipe_pending_f())
55 clear_intr |= ce_blockpipe_isr(g, ce_intr);
56
57 if (ce_intr & ce_intr_status_launcherr_pending_f())
58 clear_intr |= ce_launcherr_isr(g, ce_intr);
59
60 gk20a_writel(g, ce_intr_status_r(inst_id), clear_intr);
61 return;
62}
63
64static void gp10b_ce_nonstall_isr(struct gk20a *g, u32 inst_id, u32 pri_base)
65{
66 u32 ce_intr = gk20a_readl(g, ce_intr_status_r(inst_id));
67
68 gk20a_dbg(gpu_dbg_intr, "ce nonstall isr %08x %08x\n", ce_intr, inst_id);
69
70 if (ce_intr & ce_intr_status_nonblockpipe_pending_f()) {
71 gk20a_writel(g, ce_intr_status_r(inst_id),
72 ce_intr_status_nonblockpipe_pending_f());
73 ce_nonblockpipe_isr(g, ce_intr);
74 }
75
76 return;
77}
78void gp10b_init_ce(struct gpu_ops *gops)
79{
80 gops->ce2.isr_stall = gp10b_ce_isr;
81 gops->ce2.isr_nonstall = gp10b_ce_nonstall_isr;
82}
diff --git a/drivers/gpu/nvgpu/gp10b/ce_gp10b.h b/drivers/gpu/nvgpu/gp10b/ce_gp10b.h
new file mode 100644
index 00000000..948d0454
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/ce_gp10b.h
@@ -0,0 +1,26 @@
1/*
2 * Pascal GPU series Copy Engine.
3 *
4 * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program.
17 */
18#ifndef __CE_GP10B_H__
19#define __CE_GP10B_H__
20
21#include "gk20a/channel_gk20a.h"
22#include "gk20a/tsg_gk20a.h"
23
24void gp10b_init_ce(struct gpu_ops *gops);
25
26#endif /*__CE2_GP10B_H__*/
diff --git a/drivers/gpu/nvgpu/gp10b/fb_gp10b.c b/drivers/gpu/nvgpu/gp10b/fb_gp10b.c
new file mode 100644
index 00000000..5324b5ef
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/fb_gp10b.c
@@ -0,0 +1,108 @@
1/*
2 * GP10B FB
3 *
4 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
5*
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/types.h>
17
18#include "gk20a/gk20a.h"
19#include "gm20b/fb_gm20b.h"
20#include "gk20a/kind_gk20a.h"
21
22#include "hw_gmmu_gp10b.h"
23
24static void gp10b_init_uncompressed_kind_map(void)
25{
26 gk20a_uc_kind_map[gmmu_pte_kind_z16_2cz_v()] =
27 gk20a_uc_kind_map[gmmu_pte_kind_z16_ms2_2cz_v()] =
28 gk20a_uc_kind_map[gmmu_pte_kind_z16_ms4_2cz_v()] =
29 gk20a_uc_kind_map[gmmu_pte_kind_z16_ms8_2cz_v()] =
30 gk20a_uc_kind_map[gmmu_pte_kind_z16_ms16_2cz_v()] =
31 gmmu_pte_kind_z16_v();
32
33 gk20a_uc_kind_map[gmmu_pte_kind_c32_ms4_4cbra_v()] =
34 gk20a_uc_kind_map[gmmu_pte_kind_c64_ms4_4cbra_v()] =
35 gmmu_pte_kind_generic_16bx2_v();
36}
37
38static bool gp10b_kind_supported(u8 k)
39{
40 return (k >= gmmu_pte_kind_z16_2cz_v() &&
41 k <= gmmu_pte_kind_z16_ms8_2cz_v())
42 || k == gmmu_pte_kind_z16_ms16_2cz_v()
43 || k == gmmu_pte_kind_c32_ms4_4cbra_v()
44 || k == gmmu_pte_kind_c64_ms4_4cbra_v();
45}
46
47static bool gp10b_kind_z(u8 k)
48{
49 return (k >= gmmu_pte_kind_z16_2cz_v() &&
50 k <= gmmu_pte_kind_z16_ms8_2cz_v()) ||
51 k == gmmu_pte_kind_z16_ms16_2cz_v();
52}
53
54static bool gp10b_kind_compressible(u8 k)
55{
56 return (k >= gmmu_pte_kind_z16_2cz_v() &&
57 k <= gmmu_pte_kind_z16_ms8_2cz_v()) ||
58 k == gmmu_pte_kind_z16_ms16_2cz_v() ||
59 (k >= gmmu_pte_kind_z16_4cz_v() &&
60 k <= gmmu_pte_kind_z16_ms16_4cz_v()) ||
61 k == gmmu_pte_kind_c32_ms4_4cbra_v() ||
62 k == gmmu_pte_kind_c64_ms4_4cbra_v();
63}
64
65static bool gp10b_kind_zbc(u8 k)
66{
67 return (k >= gmmu_pte_kind_z16_2cz_v() &&
68 k <= gmmu_pte_kind_z16_ms8_2cz_v()) ||
69 k == gmmu_pte_kind_z16_ms16_2cz_v() ||
70 k == gmmu_pte_kind_c32_ms4_4cbra_v() ||
71 k == gmmu_pte_kind_c64_ms4_4cbra_v();
72}
73
74static void gp10b_init_kind_attr(void)
75{
76 u16 k;
77
78 for (k = 0; k < 256; k++) {
79 if (gp10b_kind_supported((u8)k))
80 gk20a_kind_attr[k] |= GK20A_KIND_ATTR_SUPPORTED;
81 if (gp10b_kind_compressible((u8)k))
82 gk20a_kind_attr[k] |= GK20A_KIND_ATTR_COMPRESSIBLE;
83 if (gp10b_kind_z((u8)k))
84 gk20a_kind_attr[k] |= GK20A_KIND_ATTR_Z;
85 if (gp10b_kind_zbc((u8)k))
86 gk20a_kind_attr[k] |= GK20A_KIND_ATTR_ZBC;
87 }
88}
89
90static unsigned int gp10b_fb_compression_page_size(struct gk20a *g)
91{
92 return SZ_64K;
93}
94
95static unsigned int gp10b_fb_compressible_page_size(struct gk20a *g)
96{
97 return SZ_4K;
98}
99
100void gp10b_init_fb(struct gpu_ops *gops)
101{
102 gm20b_init_fb(gops);
103 gops->fb.compression_page_size = gp10b_fb_compression_page_size;
104 gops->fb.compressible_page_size = gp10b_fb_compressible_page_size;
105
106 gp10b_init_uncompressed_kind_map();
107 gp10b_init_kind_attr();
108}
diff --git a/drivers/gpu/nvgpu/gp10b/fb_gp10b.h b/drivers/gpu/nvgpu/gp10b/fb_gp10b.h
new file mode 100644
index 00000000..76efd331
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/fb_gp10b.h
@@ -0,0 +1,21 @@
1/*
2 * GP10B FB
3 *
4 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _NVGPU_GP10B_FB
17#define _NVGPU_GP10B_FB
18struct gpu_ops;
19
20void gp10b_init_fb(struct gpu_ops *gops);
21#endif
diff --git a/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.c b/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.c
new file mode 100644
index 00000000..7dd200a9
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.c
@@ -0,0 +1,53 @@
1/*
2 * GP10B GPU FECS traces
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include "gk20a/gk20a.h"
17#include "gk20a/fecs_trace_gk20a.h"
18#include "gp10b/hw_ctxsw_prog_gp10b.h"
19#include "gp10b/hw_gr_gp10b.h"
20
21#ifdef CONFIG_GK20A_CTXSW_TRACE
22static int gp10b_fecs_trace_flush(struct gk20a *g)
23{
24 struct fecs_method_op_gk20a op = {
25 .mailbox = { .id = 0, .data = 0,
26 .clr = ~0, .ok = 0, .fail = 0},
27 .method.addr = gr_fecs_method_push_adr_write_timestamp_record_v(),
28 .method.data = 0,
29 .cond.ok = GR_IS_UCODE_OP_NOT_EQUAL,
30 .cond.fail = GR_IS_UCODE_OP_SKIP,
31 };
32 int err;
33
34 gk20a_dbg(gpu_dbg_fn|gpu_dbg_ctxsw, "");
35
36 err = gr_gk20a_elpg_protected_call(g,
37 gr_gk20a_submit_fecs_method_op(g, op, false));
38 if (err)
39 gk20a_err(dev_from_gk20a(g), "write timestamp record failed");
40
41 return err;
42}
43
44void gp10b_init_fecs_trace_ops(struct gpu_ops *ops)
45{
46 gk20a_init_fecs_trace_ops(ops);
47 ops->fecs_trace.flush = gp10b_fecs_trace_flush;
48}
49#else
50void gp10b_init_fecs_trace_ops(struct gpu_ops *ops)
51{
52}
53#endif /* CONFIG_GK20A_CTXSW_TRACE */
diff --git a/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.h b/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.h
new file mode 100644
index 00000000..2a25f4f6
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/fecs_trace_gp10b.h
@@ -0,0 +1,23 @@
1/*
2 * GP10B GPU FECS traces
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _NVGPU_FECS_TRACE_GP10B_H_
17#define _NVGPU_FECS_TRACE_GP10B_H_
18
19struct gpu_ops;
20
21int gp10b_init_fecs_trace_ops(struct gpu_ops *);
22
23#endif
diff --git a/drivers/gpu/nvgpu/gp10b/fifo_gp10b.c b/drivers/gpu/nvgpu/gp10b/fifo_gp10b.c
new file mode 100644
index 00000000..40bfa2a5
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/fifo_gp10b.c
@@ -0,0 +1,238 @@
1/*
2 * GP10B fifo
3 *
4 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/delay.h>
17#include <linux/types.h>
18
19#include "gk20a/gk20a.h"
20#include "gm20b/fifo_gm20b.h"
21#include "hw_pbdma_gp10b.h"
22#include "fifo_gp10b.h"
23#include "hw_ccsr_gp10b.h"
24#include "hw_fifo_gp10b.h"
25#include "hw_ram_gp10b.h"
26#include "hw_top_gp10b.h"
27
28static void gp10b_set_pdb_fault_replay_flags(struct gk20a *g,
29 struct mem_desc *mem)
30{
31 u32 val;
32
33 gk20a_dbg_fn("");
34
35 val = gk20a_mem_rd32(g, mem,
36 ram_in_page_dir_base_fault_replay_tex_w());
37 val &= ~ram_in_page_dir_base_fault_replay_tex_m();
38 val |= ram_in_page_dir_base_fault_replay_tex_true_f();
39 gk20a_mem_wr32(g, mem,
40 ram_in_page_dir_base_fault_replay_tex_w(), val);
41
42 val = gk20a_mem_rd32(g, mem,
43 ram_in_page_dir_base_fault_replay_gcc_w());
44 val &= ~ram_in_page_dir_base_fault_replay_gcc_m();
45 val |= ram_in_page_dir_base_fault_replay_gcc_true_f();
46 gk20a_mem_wr32(g, mem,
47 ram_in_page_dir_base_fault_replay_gcc_w(), val);
48
49 gk20a_dbg_fn("done");
50}
51
52int channel_gp10b_commit_userd(struct channel_gk20a *c)
53{
54 u32 addr_lo;
55 u32 addr_hi;
56 struct gk20a *g = c->g;
57
58 gk20a_dbg_fn("");
59
60 addr_lo = u64_lo32(c->userd_iova >> ram_userd_base_shift_v());
61 addr_hi = u64_hi32(c->userd_iova);
62
63 gk20a_dbg_info("channel %d : set ramfc userd 0x%16llx",
64 c->hw_chid, (u64)c->userd_iova);
65
66 gk20a_mem_wr32(g, &c->inst_block,
67 ram_in_ramfc_w() + ram_fc_userd_w(),
68 (g->mm.vidmem_is_vidmem ?
69 pbdma_userd_target_sys_mem_ncoh_f() :
70 pbdma_userd_target_vid_mem_f()) |
71 pbdma_userd_addr_f(addr_lo));
72
73 gk20a_mem_wr32(g, &c->inst_block,
74 ram_in_ramfc_w() + ram_fc_userd_hi_w(),
75 pbdma_userd_hi_addr_f(addr_hi));
76
77 return 0;
78}
79
80static int channel_gp10b_setup_ramfc(struct channel_gk20a *c,
81 u64 gpfifo_base, u32 gpfifo_entries, u32 flags)
82{
83 struct gk20a *g = c->g;
84 struct mem_desc *mem = &c->inst_block;
85
86 gk20a_dbg_fn("");
87
88 gk20a_memset(g, mem, 0, 0, ram_fc_size_val_v());
89
90 gk20a_mem_wr32(g, mem, ram_fc_gp_base_w(),
91 pbdma_gp_base_offset_f(
92 u64_lo32(gpfifo_base >> pbdma_gp_base_rsvd_s())));
93
94 gk20a_mem_wr32(g, mem, ram_fc_gp_base_hi_w(),
95 pbdma_gp_base_hi_offset_f(u64_hi32(gpfifo_base)) |
96 pbdma_gp_base_hi_limit2_f(ilog2(gpfifo_entries)));
97
98 gk20a_mem_wr32(g, mem, ram_fc_signature_w(),
99 c->g->ops.fifo.get_pbdma_signature(c->g));
100
101 gk20a_mem_wr32(g, mem, ram_fc_formats_w(),
102 pbdma_formats_gp_fermi0_f() |
103 pbdma_formats_pb_fermi1_f() |
104 pbdma_formats_mp_fermi0_f());
105
106 gk20a_mem_wr32(g, mem, ram_fc_pb_header_w(),
107 pbdma_pb_header_priv_user_f() |
108 pbdma_pb_header_method_zero_f() |
109 pbdma_pb_header_subchannel_zero_f() |
110 pbdma_pb_header_level_main_f() |
111 pbdma_pb_header_first_true_f() |
112 pbdma_pb_header_type_inc_f());
113
114 gk20a_mem_wr32(g, mem, ram_fc_subdevice_w(),
115 pbdma_subdevice_id_f(1) |
116 pbdma_subdevice_status_active_f() |
117 pbdma_subdevice_channel_dma_enable_f());
118
119 gk20a_mem_wr32(g, mem, ram_fc_target_w(), pbdma_target_engine_sw_f());
120
121 gk20a_mem_wr32(g, mem, ram_fc_acquire_w(),
122 channel_gk20a_pbdma_acquire_val(c));
123
124 gk20a_mem_wr32(g, mem, ram_fc_runlist_timeslice_w(),
125 pbdma_runlist_timeslice_timeout_128_f() |
126 pbdma_runlist_timeslice_timescale_3_f() |
127 pbdma_runlist_timeslice_enable_true_f());
128
129 if ( flags & NVGPU_ALLOC_GPFIFO_FLAGS_REPLAYABLE_FAULTS_ENABLE)
130 gp10b_set_pdb_fault_replay_flags(c->g, mem);
131
132
133 gk20a_mem_wr32(g, mem, ram_fc_chid_w(), ram_fc_chid_id_f(c->hw_chid));
134
135 if (c->is_privileged_channel) {
136 /* Set privilege level for channel */
137 gk20a_mem_wr32(g, mem, ram_fc_config_w(),
138 pbdma_config_auth_level_privileged_f());
139
140 gk20a_channel_setup_ramfc_for_privileged_channel(c);
141 }
142
143 return channel_gp10b_commit_userd(c);
144}
145
146static u32 gp10b_fifo_get_pbdma_signature(struct gk20a *g)
147{
148 return g->gpu_characteristics.gpfifo_class
149 | pbdma_signature_sw_zero_f();
150}
151
152static int gp10b_fifo_resetup_ramfc(struct channel_gk20a *c)
153{
154 u32 new_syncpt = 0, old_syncpt;
155 u32 v;
156
157 gk20a_dbg_fn("");
158
159 v = gk20a_mem_rd32(c->g, &c->inst_block,
160 ram_fc_allowed_syncpoints_w());
161 old_syncpt = pbdma_allowed_syncpoints_0_index_v(v);
162 if (c->sync)
163 new_syncpt = c->sync->syncpt_id(c->sync);
164
165 if (new_syncpt && new_syncpt != old_syncpt) {
166 /* disable channel */
167 gk20a_disable_channel_tsg(c->g, c);
168
169 /* preempt the channel */
170 WARN_ON(gk20a_fifo_preempt(c->g, c));
171
172 v = pbdma_allowed_syncpoints_0_valid_f(1);
173
174 gk20a_dbg_info("Channel %d, syncpt id %d\n",
175 c->hw_chid, new_syncpt);
176
177 v |= pbdma_allowed_syncpoints_0_index_f(new_syncpt);
178
179 gk20a_mem_wr32(c->g, &c->inst_block,
180 ram_fc_allowed_syncpoints_w(), v);
181 }
182
183 /* enable channel */
184 gk20a_enable_channel_tsg(c->g, c);
185
186 gk20a_dbg_fn("done");
187
188 return 0;
189}
190
191static int gp10b_fifo_engine_enum_from_type(struct gk20a *g, u32 engine_type,
192 u32 *inst_id)
193{
194 int ret = ENGINE_INVAL_GK20A;
195
196 gk20a_dbg_info("engine type %d", engine_type);
197 if (engine_type == top_device_info_type_enum_graphics_v())
198 ret = ENGINE_GR_GK20A;
199 else if (engine_type == top_device_info_type_enum_lce_v()) {
200 /* Default assumptions - all the CE engine have separate runlist */
201 ret = ENGINE_ASYNC_CE_GK20A;
202 }
203
204 return ret;
205}
206
207static void gp10b_device_info_data_parse(struct gk20a *g, u32 table_entry,
208 u32 *inst_id, u32 *pri_base, u32 *fault_id)
209{
210 if (top_device_info_data_type_v(table_entry) ==
211 top_device_info_data_type_enum2_v()) {
212 if (inst_id)
213 *inst_id = top_device_info_data_inst_id_v(table_entry);
214 if (pri_base) {
215 *pri_base =
216 (top_device_info_data_pri_base_v(table_entry)
217 << top_device_info_data_pri_base_align_v());
218 }
219 if (fault_id && (top_device_info_data_fault_id_v(table_entry) ==
220 top_device_info_data_fault_id_valid_v())) {
221 *fault_id =
222 top_device_info_data_fault_id_enum_v(table_entry);
223 }
224 } else
225 gk20a_err(g->dev, "unknown device_info_data %d",
226 top_device_info_data_type_v(table_entry));
227}
228
229void gp10b_init_fifo(struct gpu_ops *gops)
230{
231 gm20b_init_fifo(gops);
232 gops->fifo.setup_ramfc = channel_gp10b_setup_ramfc;
233 gops->fifo.get_pbdma_signature = gp10b_fifo_get_pbdma_signature;
234 gops->fifo.resetup_ramfc = gp10b_fifo_resetup_ramfc;
235 gops->fifo.engine_enum_from_type = gp10b_fifo_engine_enum_from_type;
236 gops->fifo.device_info_data_parse = gp10b_device_info_data_parse;
237 gops->fifo.eng_runlist_base_size = fifo_eng_runlist_base__size_1_v;
238}
diff --git a/drivers/gpu/nvgpu/gp10b/fifo_gp10b.h b/drivers/gpu/nvgpu/gp10b/fifo_gp10b.h
new file mode 100644
index 00000000..3ef8247f
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/fifo_gp10b.h
@@ -0,0 +1,21 @@
1/*
2 * GP10B Fifo
3 *
4 * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef FIFO_GP10B_H
17#define FIFO_GP10B_H
18struct gpu_ops;
19void gp10b_init_fifo(struct gpu_ops *gops);
20int channel_gp10b_commit_userd(struct channel_gk20a *c);
21#endif
diff --git a/drivers/gpu/nvgpu/gp10b/gp10b.c b/drivers/gpu/nvgpu/gp10b/gp10b.c
new file mode 100644
index 00000000..a541dda3
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gp10b.c
@@ -0,0 +1,110 @@
1/*
2 * GP10B Graphics
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include "gk20a/gk20a.h"
20#include "hw_fuse_gp10b.h"
21#include "hw_gr_gp10b.h"
22
23static u64 gp10b_detect_ecc_enabled_units(struct gk20a *g)
24{
25 u64 ecc_enabled_units = 0;
26 u32 opt_ecc_en = gk20a_readl(g, fuse_opt_ecc_en_r());
27 u32 opt_feature_fuses_override_disable =
28 gk20a_readl(g,
29 fuse_opt_feature_fuses_override_disable_r());
30 u32 fecs_feature_override_ecc =
31 gk20a_readl(g,
32 gr_fecs_feature_override_ecc_r());
33
34 if (opt_feature_fuses_override_disable) {
35 if (opt_ecc_en)
36 ecc_enabled_units = NVGPU_GPU_FLAGS_ALL_ECC_ENABLED;
37 else
38 ecc_enabled_units = 0;
39 } else {
40 /* SM LRF */
41 if (gr_fecs_feature_override_ecc_sm_lrf_override_v(
42 fecs_feature_override_ecc)) {
43 if (gr_fecs_feature_override_ecc_sm_lrf_v(
44 fecs_feature_override_ecc)) {
45 ecc_enabled_units |=
46 NVGPU_GPU_FLAGS_ECC_ENABLED_SM_LRF;
47 }
48 } else {
49 if (opt_ecc_en) {
50 ecc_enabled_units |=
51 NVGPU_GPU_FLAGS_ECC_ENABLED_SM_LRF;
52 }
53 }
54
55 /* SM SHM */
56 if (gr_fecs_feature_override_ecc_sm_shm_override_v(
57 fecs_feature_override_ecc)) {
58 if (gr_fecs_feature_override_ecc_sm_shm_v(
59 fecs_feature_override_ecc)) {
60 ecc_enabled_units |=
61 NVGPU_GPU_FLAGS_ECC_ENABLED_SM_SHM;
62 }
63 } else {
64 if (opt_ecc_en) {
65 ecc_enabled_units |=
66 NVGPU_GPU_FLAGS_ECC_ENABLED_SM_SHM;
67 }
68 }
69
70 /* TEX */
71 if (gr_fecs_feature_override_ecc_tex_override_v(
72 fecs_feature_override_ecc)) {
73 if (gr_fecs_feature_override_ecc_tex_v(
74 fecs_feature_override_ecc)) {
75 ecc_enabled_units |=
76 NVGPU_GPU_FLAGS_ECC_ENABLED_TEX;
77 }
78 } else {
79 if (opt_ecc_en) {
80 ecc_enabled_units |=
81 NVGPU_GPU_FLAGS_ECC_ENABLED_TEX;
82 }
83 }
84
85 /* LTC */
86 if (gr_fecs_feature_override_ecc_ltc_override_v(
87 fecs_feature_override_ecc)) {
88 if (gr_fecs_feature_override_ecc_ltc_v(
89 fecs_feature_override_ecc)) {
90 ecc_enabled_units |=
91 NVGPU_GPU_FLAGS_ECC_ENABLED_LTC;
92 }
93 } else {
94 if (opt_ecc_en) {
95 ecc_enabled_units |=
96 NVGPU_GPU_FLAGS_ECC_ENABLED_LTC;
97 }
98 }
99 }
100
101 return ecc_enabled_units;
102}
103
104int gp10b_init_gpu_characteristics(struct gk20a *g)
105{
106 gk20a_init_gpu_characteristics(g);
107 g->gpu_characteristics.flags |= gp10b_detect_ecc_enabled_units(g);
108
109 return 0;
110}
diff --git a/drivers/gpu/nvgpu/gp10b/gp10b.h b/drivers/gpu/nvgpu/gp10b/gp10b.h
new file mode 100644
index 00000000..263f3cbe
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gp10b.h
@@ -0,0 +1,26 @@
1/*
2 * GP10B Graphics
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef GP10B_H
20#define GP10B_H
21
22#include "gk20a/gk20a.h"
23
24int gp10b_init_gpu_characteristics(struct gk20a *g);
25
26#endif /* GP10B_H */
diff --git a/drivers/gpu/nvgpu/gp10b/gp10b_gating_reglist.c b/drivers/gpu/nvgpu/gp10b/gp10b_gating_reglist.c
new file mode 100644
index 00000000..563819de
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gp10b_gating_reglist.c
@@ -0,0 +1,640 @@
1/*
2 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License.
7 *
8 * This program is distributed in the hope that 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 along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 *
17 * This file is autogenerated. Do not edit.
18 */
19
20#ifndef __gp10b_gating_reglist_h__
21#define __gp10b_gating_reglist_h__
22
23#include <linux/types.h>
24#include "gp10b_gating_reglist.h"
25
26struct gating_desc {
27 u32 addr;
28 u32 prod;
29 u32 disable;
30};
31/* slcg bus */
32static const struct gating_desc gp10b_slcg_bus[] = {
33 {.addr = 0x00001c04, .prod = 0x00000000, .disable = 0x000003fe},
34};
35
36/* slcg ce2 */
37static const struct gating_desc gp10b_slcg_ce2[] = {
38 {.addr = 0x00104204, .prod = 0x00000000, .disable = 0x000007fe},
39};
40
41/* slcg chiplet */
42static const struct gating_desc gp10b_slcg_chiplet[] = {
43 {.addr = 0x0010c07c, .prod = 0x00000000, .disable = 0x00000007},
44 {.addr = 0x0010e07c, .prod = 0x00000000, .disable = 0x00000007},
45 {.addr = 0x0010d07c, .prod = 0x00000000, .disable = 0x00000007},
46 {.addr = 0x0010e17c, .prod = 0x00000000, .disable = 0x00000007},
47};
48
49/* slcg fb */
50static const struct gating_desc gp10b_slcg_fb[] = {
51 {.addr = 0x00100d14, .prod = 0x00000000, .disable = 0xfffffffe},
52 {.addr = 0x00100c9c, .prod = 0x00000000, .disable = 0x000001fe},
53};
54
55/* slcg fifo */
56static const struct gating_desc gp10b_slcg_fifo[] = {
57 {.addr = 0x000026ac, .prod = 0x00000f40, .disable = 0x0001fffe},
58};
59
60/* slcg gr */
61static const struct gating_desc gp10b_slcg_gr[] = {
62 {.addr = 0x004041f4, .prod = 0x00000002, .disable = 0x03fffffe},
63 {.addr = 0x0040917c, .prod = 0x00020008, .disable = 0x0003fffe},
64 {.addr = 0x00409894, .prod = 0x00000040, .disable = 0x03fffffe},
65 {.addr = 0x004078c4, .prod = 0x00000000, .disable = 0x000001fe},
66 {.addr = 0x00406004, .prod = 0x00000000, .disable = 0x0001fffe},
67 {.addr = 0x00405864, .prod = 0x00000000, .disable = 0x000001fe},
68 {.addr = 0x00405910, .prod = 0xfffffff0, .disable = 0xfffffffe},
69 {.addr = 0x00408044, .prod = 0x00000000, .disable = 0x000007fe},
70 {.addr = 0x00407004, .prod = 0x00000000, .disable = 0x000001fe},
71 {.addr = 0x0041a17c, .prod = 0x00020008, .disable = 0x0003fffe},
72 {.addr = 0x0041a894, .prod = 0x00000040, .disable = 0x03fffffe},
73 {.addr = 0x00418504, .prod = 0x00000000, .disable = 0x0007fffe},
74 {.addr = 0x0041860c, .prod = 0x00000000, .disable = 0x000001fe},
75 {.addr = 0x0041868c, .prod = 0x00000000, .disable = 0x0000001e},
76 {.addr = 0x0041871c, .prod = 0x00000000, .disable = 0x0000003e},
77 {.addr = 0x00418388, .prod = 0x00000000, .disable = 0x00000001},
78 {.addr = 0x0041882c, .prod = 0x00000000, .disable = 0x0001fffe},
79 {.addr = 0x00418bc0, .prod = 0x00000000, .disable = 0x000001fe},
80 {.addr = 0x00418974, .prod = 0x00000000, .disable = 0x0001fffe},
81 {.addr = 0x00418c74, .prod = 0xffffffc0, .disable = 0xfffffffe},
82 {.addr = 0x00418cf4, .prod = 0xfffffffc, .disable = 0xfffffffe},
83 {.addr = 0x00418d74, .prod = 0xffffffe0, .disable = 0xfffffffe},
84 {.addr = 0x00418f10, .prod = 0xffffffe0, .disable = 0xfffffffe},
85 {.addr = 0x00418e10, .prod = 0xfffffffe, .disable = 0xfffffffe},
86 {.addr = 0x00419024, .prod = 0x000001fe, .disable = 0x000001fe},
87 {.addr = 0x0041889c, .prod = 0x00000000, .disable = 0x000001fe},
88 {.addr = 0x00419d24, .prod = 0x00000000, .disable = 0x0000ffff},
89 {.addr = 0x00419a44, .prod = 0x00000000, .disable = 0x0000000e},
90 {.addr = 0x00419a4c, .prod = 0x00000000, .disable = 0x000001fe},
91 {.addr = 0x00419a54, .prod = 0x00000000, .disable = 0x0000003e},
92 {.addr = 0x00419a5c, .prod = 0x00000000, .disable = 0x0000000e},
93 {.addr = 0x00419a64, .prod = 0x00000000, .disable = 0x000001fe},
94 {.addr = 0x00419a6c, .prod = 0x00000000, .disable = 0x0000000e},
95 {.addr = 0x00419a74, .prod = 0x00000000, .disable = 0x0000000e},
96 {.addr = 0x00419a7c, .prod = 0x00000000, .disable = 0x0000003e},
97 {.addr = 0x00419a84, .prod = 0x00000000, .disable = 0x0000000e},
98 {.addr = 0x0041986c, .prod = 0x00000104, .disable = 0x00fffffe},
99 {.addr = 0x00419cd8, .prod = 0x00000000, .disable = 0x001ffffe},
100 {.addr = 0x00419ce0, .prod = 0x00000000, .disable = 0x001ffffe},
101 {.addr = 0x00419c74, .prod = 0x0000001e, .disable = 0x0000001e},
102 {.addr = 0x00419fd4, .prod = 0x00000000, .disable = 0x0003fffe},
103 {.addr = 0x00419fdc, .prod = 0xffedff00, .disable = 0xfffffffe},
104 {.addr = 0x00419fe4, .prod = 0x00001b00, .disable = 0x00001ffe},
105 {.addr = 0x00419ff4, .prod = 0x00000000, .disable = 0x00003ffe},
106 {.addr = 0x00419ffc, .prod = 0x00000000, .disable = 0x0001fffe},
107 {.addr = 0x0041be2c, .prod = 0x04115fc0, .disable = 0xfffffffe},
108 {.addr = 0x0041bfec, .prod = 0xfffffff0, .disable = 0xfffffffe},
109 {.addr = 0x0041bed4, .prod = 0xfffffff8, .disable = 0xfffffffe},
110 {.addr = 0x00408814, .prod = 0x00000000, .disable = 0x0001fffe},
111 {.addr = 0x00408a84, .prod = 0x00000000, .disable = 0x0001fffe},
112 {.addr = 0x004089ac, .prod = 0x00000000, .disable = 0x0001fffe},
113 {.addr = 0x00408a24, .prod = 0x00000000, .disable = 0x0000ffff},
114};
115
116/* slcg ltc */
117static const struct gating_desc gp10b_slcg_ltc[] = {
118 {.addr = 0x0017e050, .prod = 0x00000000, .disable = 0xfffffffe},
119 {.addr = 0x0017e35c, .prod = 0x00000000, .disable = 0xfffffffe},
120};
121
122/* slcg perf */
123static const struct gating_desc gp10b_slcg_perf[] = {
124 {.addr = 0x001be018, .prod = 0x000001ff, .disable = 0x00000000},
125 {.addr = 0x001bc018, .prod = 0x000001ff, .disable = 0x00000000},
126 {.addr = 0x001b8018, .prod = 0x000001ff, .disable = 0x00000000},
127 {.addr = 0x001b4124, .prod = 0x00000001, .disable = 0x00000000},
128};
129
130/* slcg PriRing */
131static const struct gating_desc gp10b_slcg_priring[] = {
132 {.addr = 0x001200a8, .prod = 0x00000000, .disable = 0x00000001},
133};
134
135/* slcg pwr_csb */
136static const struct gating_desc gp10b_slcg_pwr_csb[] = {
137 {.addr = 0x00000134, .prod = 0x00020008, .disable = 0x0003fffe},
138 {.addr = 0x00000e74, .prod = 0x00000000, .disable = 0x0000000f},
139 {.addr = 0x00000a74, .prod = 0x00004000, .disable = 0x00007ffe},
140 {.addr = 0x000016b8, .prod = 0x00000000, .disable = 0x0000000f},
141};
142
143/* slcg pmu */
144static const struct gating_desc gp10b_slcg_pmu[] = {
145 {.addr = 0x0010a134, .prod = 0x00020008, .disable = 0x0003fffe},
146 {.addr = 0x0010aa74, .prod = 0x00004000, .disable = 0x00007ffe},
147 {.addr = 0x0010ae74, .prod = 0x00000000, .disable = 0x0000000f},
148};
149
150/* therm gr */
151static const struct gating_desc gp10b_slcg_therm[] = {
152 {.addr = 0x000206b8, .prod = 0x00000000, .disable = 0x0000000f},
153};
154
155/* slcg Xbar */
156static const struct gating_desc gp10b_slcg_xbar[] = {
157 {.addr = 0x0013cbe4, .prod = 0x00000000, .disable = 0x1ffffffe},
158 {.addr = 0x0013cc04, .prod = 0x00000000, .disable = 0x1ffffffe},
159};
160
161/* blcg bus */
162static const struct gating_desc gp10b_blcg_bus[] = {
163 {.addr = 0x00001c00, .prod = 0x00000042, .disable = 0x00000000},
164};
165
166/* blcg ce */
167static const struct gating_desc gp10b_blcg_ce[] = {
168 {.addr = 0x00104200, .prod = 0x00008242, .disable = 0x00000000},
169};
170
171/* blcg ctxsw prog */
172static const struct gating_desc gp10b_blcg_ctxsw_prog[] = {
173};
174
175/* blcg fb */
176static const struct gating_desc gp10b_blcg_fb[] = {
177 {.addr = 0x00100d10, .prod = 0x0000c242, .disable = 0x00000000},
178 {.addr = 0x00100d30, .prod = 0x0000c242, .disable = 0x00000000},
179 {.addr = 0x00100d3c, .prod = 0x00000242, .disable = 0x00000000},
180 {.addr = 0x00100d48, .prod = 0x0000c242, .disable = 0x00000000},
181 {.addr = 0x00100c98, .prod = 0x00004242, .disable = 0x00000000},
182};
183
184/* blcg fifo */
185static const struct gating_desc gp10b_blcg_fifo[] = {
186 {.addr = 0x000026a4, .prod = 0x0000c242, .disable = 0x00000000},
187};
188
189/* blcg gr */
190static const struct gating_desc gp10b_blcg_gr[] = {
191 {.addr = 0x004041f0, .prod = 0x0000c646, .disable = 0x00000000},
192 {.addr = 0x00409890, .prod = 0x0000007f, .disable = 0x00000000},
193 {.addr = 0x004098b0, .prod = 0x0000007f, .disable = 0x00000000},
194 {.addr = 0x004078c0, .prod = 0x00004242, .disable = 0x00000000},
195 {.addr = 0x00406000, .prod = 0x0000c444, .disable = 0x00000000},
196 {.addr = 0x00405860, .prod = 0x0000c242, .disable = 0x00000000},
197 {.addr = 0x0040590c, .prod = 0x0000c444, .disable = 0x00000000},
198 {.addr = 0x00408040, .prod = 0x0000c444, .disable = 0x00000000},
199 {.addr = 0x00407000, .prod = 0x4000c242, .disable = 0x00000000},
200 {.addr = 0x00405bf0, .prod = 0x0000c444, .disable = 0x00000000},
201 {.addr = 0x0041a890, .prod = 0x0000427f, .disable = 0x00000000},
202 {.addr = 0x0041a8b0, .prod = 0x0000007f, .disable = 0x00000000},
203 {.addr = 0x00418500, .prod = 0x0000c244, .disable = 0x00000000},
204 {.addr = 0x00418608, .prod = 0x0000c242, .disable = 0x00000000},
205 {.addr = 0x00418688, .prod = 0x0000c242, .disable = 0x00000000},
206 {.addr = 0x00418718, .prod = 0x00000042, .disable = 0x00000000},
207 {.addr = 0x00418828, .prod = 0x00008444, .disable = 0x00000000},
208 {.addr = 0x00418bbc, .prod = 0x0000c242, .disable = 0x00000000},
209 {.addr = 0x00418970, .prod = 0x0000c242, .disable = 0x00000000},
210 {.addr = 0x00418c70, .prod = 0x0000c444, .disable = 0x00000000},
211 {.addr = 0x00418cf0, .prod = 0x0000c444, .disable = 0x00000000},
212 {.addr = 0x00418d70, .prod = 0x0000c444, .disable = 0x00000000},
213 {.addr = 0x00418f0c, .prod = 0x0000c444, .disable = 0x00000000},
214 {.addr = 0x00418e0c, .prod = 0x00008444, .disable = 0x00000000},
215 {.addr = 0x00419020, .prod = 0x0000c242, .disable = 0x00000000},
216 {.addr = 0x00419038, .prod = 0x00000042, .disable = 0x00000000},
217 {.addr = 0x00418898, .prod = 0x00004242, .disable = 0x00000000},
218 {.addr = 0x00419a40, .prod = 0x0000c242, .disable = 0x00000000},
219 {.addr = 0x00419a48, .prod = 0x0000c242, .disable = 0x00000000},
220 {.addr = 0x00419a50, .prod = 0x0000c242, .disable = 0x00000000},
221 {.addr = 0x00419a58, .prod = 0x0000c242, .disable = 0x00000000},
222 {.addr = 0x00419a60, .prod = 0x0000c242, .disable = 0x00000000},
223 {.addr = 0x00419a68, .prod = 0x0000c242, .disable = 0x00000000},
224 {.addr = 0x00419a70, .prod = 0x0000c242, .disable = 0x00000000},
225 {.addr = 0x00419a78, .prod = 0x0000c242, .disable = 0x00000000},
226 {.addr = 0x00419a80, .prod = 0x0000c242, .disable = 0x00000000},
227 {.addr = 0x00419868, .prod = 0x00008242, .disable = 0x00000000},
228 {.addr = 0x00419cd4, .prod = 0x00000002, .disable = 0x00000000},
229 {.addr = 0x00419cdc, .prod = 0x00000002, .disable = 0x00000000},
230 {.addr = 0x00419c70, .prod = 0x0000c444, .disable = 0x00000000},
231 {.addr = 0x00419fd0, .prod = 0x0000c044, .disable = 0x00000000},
232 {.addr = 0x00419fd8, .prod = 0x0000c046, .disable = 0x00000000},
233 {.addr = 0x00419fe0, .prod = 0x0000c044, .disable = 0x00000000},
234 {.addr = 0x00419fe8, .prod = 0x0000c042, .disable = 0x00000000},
235 {.addr = 0x00419ff0, .prod = 0x0000c045, .disable = 0x00000000},
236 {.addr = 0x00419ff8, .prod = 0x00000002, .disable = 0x00000000},
237 {.addr = 0x00419f90, .prod = 0x00000002, .disable = 0x00000000},
238 {.addr = 0x0041be28, .prod = 0x00008242, .disable = 0x00000000},
239 {.addr = 0x0041bfe8, .prod = 0x0000c444, .disable = 0x00000000},
240 {.addr = 0x0041bed0, .prod = 0x0000c444, .disable = 0x00000000},
241 {.addr = 0x00408810, .prod = 0x0000c242, .disable = 0x00000000},
242 {.addr = 0x00408a80, .prod = 0x0000c242, .disable = 0x00000000},
243 {.addr = 0x004089a8, .prod = 0x0000c242, .disable = 0x00000000},
244};
245
246/* blcg ltc */
247static const struct gating_desc gp10b_blcg_ltc[] = {
248 {.addr = 0x0017e030, .prod = 0x00000044, .disable = 0x00000000},
249 {.addr = 0x0017e040, .prod = 0x00000044, .disable = 0x00000000},
250 {.addr = 0x0017e3e0, .prod = 0x00000044, .disable = 0x00000000},
251 {.addr = 0x0017e3c8, .prod = 0x00000044, .disable = 0x00000000},
252};
253
254/* blcg pwr_csb */
255static const struct gating_desc gp10b_blcg_pwr_csb[] = {
256 {.addr = 0x00000a70, .prod = 0x00000045, .disable = 0x00000000},
257};
258
259/* blcg pmu */
260static const struct gating_desc gp10b_blcg_pmu[] = {
261 {.addr = 0x0010aa70, .prod = 0x00000045, .disable = 0x00000000},
262};
263
264/* blcg Xbar */
265static const struct gating_desc gp10b_blcg_xbar[] = {
266 {.addr = 0x0013cbe0, .prod = 0x00000042, .disable = 0x00000000},
267 {.addr = 0x0013cc00, .prod = 0x00000042, .disable = 0x00000000},
268};
269
270/* pg gr */
271static const struct gating_desc gp10b_pg_gr[] = {
272};
273
274/* inline functions */
275void gp10b_slcg_bus_load_gating_prod(struct gk20a *g,
276 bool prod)
277{
278 u32 i;
279 u32 size = sizeof(gp10b_slcg_bus) / sizeof(struct gating_desc);
280 for (i = 0; i < size; i++) {
281 if (prod)
282 gk20a_writel(g, gp10b_slcg_bus[i].addr,
283 gp10b_slcg_bus[i].prod);
284 else
285 gk20a_writel(g, gp10b_slcg_bus[i].addr,
286 gp10b_slcg_bus[i].disable);
287 }
288}
289
290void gp10b_slcg_ce2_load_gating_prod(struct gk20a *g,
291 bool prod)
292{
293 u32 i;
294 u32 size = sizeof(gp10b_slcg_ce2) / sizeof(struct gating_desc);
295 for (i = 0; i < size; i++) {
296 if (prod)
297 gk20a_writel(g, gp10b_slcg_ce2[i].addr,
298 gp10b_slcg_ce2[i].prod);
299 else
300 gk20a_writel(g, gp10b_slcg_ce2[i].addr,
301 gp10b_slcg_ce2[i].disable);
302 }
303}
304
305void gp10b_slcg_chiplet_load_gating_prod(struct gk20a *g,
306 bool prod)
307{
308 u32 i;
309 u32 size = sizeof(gp10b_slcg_chiplet) / sizeof(struct gating_desc);
310 for (i = 0; i < size; i++) {
311 if (prod)
312 gk20a_writel(g, gp10b_slcg_chiplet[i].addr,
313 gp10b_slcg_chiplet[i].prod);
314 else
315 gk20a_writel(g, gp10b_slcg_chiplet[i].addr,
316 gp10b_slcg_chiplet[i].disable);
317 }
318}
319
320void gp10b_slcg_ctxsw_firmware_load_gating_prod(struct gk20a *g,
321 bool prod)
322{
323}
324
325void gp10b_slcg_fb_load_gating_prod(struct gk20a *g,
326 bool prod)
327{
328 u32 i;
329 u32 size = sizeof(gp10b_slcg_fb) / sizeof(struct gating_desc);
330 for (i = 0; i < size; i++) {
331 if (prod)
332 gk20a_writel(g, gp10b_slcg_fb[i].addr,
333 gp10b_slcg_fb[i].prod);
334 else
335 gk20a_writel(g, gp10b_slcg_fb[i].addr,
336 gp10b_slcg_fb[i].disable);
337 }
338}
339
340void gp10b_slcg_fifo_load_gating_prod(struct gk20a *g,
341 bool prod)
342{
343 u32 i;
344 u32 size = sizeof(gp10b_slcg_fifo) / sizeof(struct gating_desc);
345 for (i = 0; i < size; i++) {
346 if (prod)
347 gk20a_writel(g, gp10b_slcg_fifo[i].addr,
348 gp10b_slcg_fifo[i].prod);
349 else
350 gk20a_writel(g, gp10b_slcg_fifo[i].addr,
351 gp10b_slcg_fifo[i].disable);
352 }
353}
354
355void gr_gp10b_slcg_gr_load_gating_prod(struct gk20a *g,
356 bool prod)
357{
358 u32 i;
359 u32 size = sizeof(gp10b_slcg_gr) / sizeof(struct gating_desc);
360 for (i = 0; i < size; i++) {
361 if (prod)
362 gk20a_writel(g, gp10b_slcg_gr[i].addr,
363 gp10b_slcg_gr[i].prod);
364 else
365 gk20a_writel(g, gp10b_slcg_gr[i].addr,
366 gp10b_slcg_gr[i].disable);
367 }
368}
369
370void ltc_gp10b_slcg_ltc_load_gating_prod(struct gk20a *g,
371 bool prod)
372{
373 u32 i;
374 u32 size = sizeof(gp10b_slcg_ltc) / sizeof(struct gating_desc);
375 for (i = 0; i < size; i++) {
376 if (prod)
377 gk20a_writel(g, gp10b_slcg_ltc[i].addr,
378 gp10b_slcg_ltc[i].prod);
379 else
380 gk20a_writel(g, gp10b_slcg_ltc[i].addr,
381 gp10b_slcg_ltc[i].disable);
382 }
383}
384
385void gp10b_slcg_perf_load_gating_prod(struct gk20a *g,
386 bool prod)
387{
388 u32 i;
389 u32 size = sizeof(gp10b_slcg_perf) / sizeof(struct gating_desc);
390 for (i = 0; i < size; i++) {
391 if (prod)
392 gk20a_writel(g, gp10b_slcg_perf[i].addr,
393 gp10b_slcg_perf[i].prod);
394 else
395 gk20a_writel(g, gp10b_slcg_perf[i].addr,
396 gp10b_slcg_perf[i].disable);
397 }
398}
399
400void gp10b_slcg_priring_load_gating_prod(struct gk20a *g,
401 bool prod)
402{
403 u32 i;
404 u32 size = sizeof(gp10b_slcg_priring) / sizeof(struct gating_desc);
405 for (i = 0; i < size; i++) {
406 if (prod)
407 gk20a_writel(g, gp10b_slcg_priring[i].addr,
408 gp10b_slcg_priring[i].prod);
409 else
410 gk20a_writel(g, gp10b_slcg_priring[i].addr,
411 gp10b_slcg_priring[i].disable);
412 }
413}
414
415void gp10b_slcg_pwr_csb_load_gating_prod(struct gk20a *g,
416 bool prod)
417{
418 u32 i;
419 u32 size = sizeof(gp10b_slcg_pwr_csb) / sizeof(struct gating_desc);
420 for (i = 0; i < size; i++) {
421 if (prod)
422 gk20a_writel(g, gp10b_slcg_pwr_csb[i].addr,
423 gp10b_slcg_pwr_csb[i].prod);
424 else
425 gk20a_writel(g, gp10b_slcg_pwr_csb[i].addr,
426 gp10b_slcg_pwr_csb[i].disable);
427 }
428}
429
430void gp10b_slcg_pmu_load_gating_prod(struct gk20a *g,
431 bool prod)
432{
433 u32 i;
434 u32 size = sizeof(gp10b_slcg_pmu) / sizeof(struct gating_desc);
435 for (i = 0; i < size; i++) {
436 if (prod)
437 gk20a_writel(g, gp10b_slcg_pmu[i].addr,
438 gp10b_slcg_pmu[i].prod);
439 else
440 gk20a_writel(g, gp10b_slcg_pmu[i].addr,
441 gp10b_slcg_pmu[i].disable);
442 }
443}
444
445void gp10b_slcg_therm_load_gating_prod(struct gk20a *g,
446 bool prod)
447{
448 u32 i;
449 u32 size = sizeof(gp10b_slcg_therm) / sizeof(struct gating_desc);
450 for (i = 0; i < size; i++) {
451 if (prod)
452 gk20a_writel(g, gp10b_slcg_therm[i].addr,
453 gp10b_slcg_therm[i].prod);
454 else
455 gk20a_writel(g, gp10b_slcg_therm[i].addr,
456 gp10b_slcg_therm[i].disable);
457 }
458}
459
460void gp10b_slcg_xbar_load_gating_prod(struct gk20a *g,
461 bool prod)
462{
463 u32 i;
464 u32 size = sizeof(gp10b_slcg_xbar) / sizeof(struct gating_desc);
465 for (i = 0; i < size; i++) {
466 if (prod)
467 gk20a_writel(g, gp10b_slcg_xbar[i].addr,
468 gp10b_slcg_xbar[i].prod);
469 else
470 gk20a_writel(g, gp10b_slcg_xbar[i].addr,
471 gp10b_slcg_xbar[i].disable);
472 }
473}
474
475void gp10b_blcg_bus_load_gating_prod(struct gk20a *g,
476 bool prod)
477{
478 u32 i;
479 u32 size = sizeof(gp10b_blcg_bus) / sizeof(struct gating_desc);
480 for (i = 0; i < size; i++) {
481 if (prod)
482 gk20a_writel(g, gp10b_blcg_bus[i].addr,
483 gp10b_blcg_bus[i].prod);
484 else
485 gk20a_writel(g, gp10b_blcg_bus[i].addr,
486 gp10b_blcg_bus[i].disable);
487 }
488}
489
490void gp10b_blcg_ce_load_gating_prod(struct gk20a *g,
491 bool prod)
492{
493 u32 i;
494 u32 size = sizeof(gp10b_blcg_ce) / sizeof(struct gating_desc);
495 for (i = 0; i < size; i++) {
496 if (prod)
497 gk20a_writel(g, gp10b_blcg_ce[i].addr,
498 gp10b_blcg_ce[i].prod);
499 else
500 gk20a_writel(g, gp10b_blcg_ce[i].addr,
501 gp10b_blcg_ce[i].disable);
502 }
503}
504
505void gp10b_blcg_ctxsw_firmware_load_gating_prod(struct gk20a *g,
506 bool prod)
507{
508 u32 i;
509 u32 size = sizeof(gp10b_blcg_ctxsw_prog) / sizeof(struct gating_desc);
510 for (i = 0; i < size; i++) {
511 if (prod)
512 gk20a_writel(g, gp10b_blcg_ctxsw_prog[i].addr,
513 gp10b_blcg_ctxsw_prog[i].prod);
514 else
515 gk20a_writel(g, gp10b_blcg_ctxsw_prog[i].addr,
516 gp10b_blcg_ctxsw_prog[i].disable);
517 }
518}
519
520void gp10b_blcg_fb_load_gating_prod(struct gk20a *g,
521 bool prod)
522{
523 u32 i;
524 u32 size = sizeof(gp10b_blcg_fb) / sizeof(struct gating_desc);
525 for (i = 0; i < size; i++) {
526 if (prod)
527 gk20a_writel(g, gp10b_blcg_fb[i].addr,
528 gp10b_blcg_fb[i].prod);
529 else
530 gk20a_writel(g, gp10b_blcg_fb[i].addr,
531 gp10b_blcg_fb[i].disable);
532 }
533}
534
535void gp10b_blcg_fifo_load_gating_prod(struct gk20a *g,
536 bool prod)
537{
538 u32 i;
539 u32 size = sizeof(gp10b_blcg_fifo) / sizeof(struct gating_desc);
540 for (i = 0; i < size; i++) {
541 if (prod)
542 gk20a_writel(g, gp10b_blcg_fifo[i].addr,
543 gp10b_blcg_fifo[i].prod);
544 else
545 gk20a_writel(g, gp10b_blcg_fifo[i].addr,
546 gp10b_blcg_fifo[i].disable);
547 }
548}
549
550void gp10b_blcg_gr_load_gating_prod(struct gk20a *g,
551 bool prod)
552{
553 u32 i;
554 u32 size = sizeof(gp10b_blcg_gr) / sizeof(struct gating_desc);
555 for (i = 0; i < size; i++) {
556 if (prod)
557 gk20a_writel(g, gp10b_blcg_gr[i].addr,
558 gp10b_blcg_gr[i].prod);
559 else
560 gk20a_writel(g, gp10b_blcg_gr[i].addr,
561 gp10b_blcg_gr[i].disable);
562 }
563}
564
565void gp10b_blcg_ltc_load_gating_prod(struct gk20a *g,
566 bool prod)
567{
568 u32 i;
569 u32 size = sizeof(gp10b_blcg_ltc) / sizeof(struct gating_desc);
570 for (i = 0; i < size; i++) {
571 if (prod)
572 gk20a_writel(g, gp10b_blcg_ltc[i].addr,
573 gp10b_blcg_ltc[i].prod);
574 else
575 gk20a_writel(g, gp10b_blcg_ltc[i].addr,
576 gp10b_blcg_ltc[i].disable);
577 }
578}
579
580void gp10b_blcg_pwr_csb_load_gating_prod(struct gk20a *g,
581 bool prod)
582{
583 u32 i;
584 u32 size = sizeof(gp10b_blcg_pwr_csb) / sizeof(struct gating_desc);
585 for (i = 0; i < size; i++) {
586 if (prod)
587 gk20a_writel(g, gp10b_blcg_pwr_csb[i].addr,
588 gp10b_blcg_pwr_csb[i].prod);
589 else
590 gk20a_writel(g, gp10b_blcg_pwr_csb[i].addr,
591 gp10b_blcg_pwr_csb[i].disable);
592 }
593}
594
595void gp10b_blcg_pmu_load_gating_prod(struct gk20a *g,
596 bool prod)
597{
598 u32 i;
599 u32 size = sizeof(gp10b_blcg_pmu) / sizeof(struct gating_desc);
600 for (i = 0; i < size; i++) {
601 if (prod)
602 gk20a_writel(g, gp10b_blcg_pmu[i].addr,
603 gp10b_blcg_pmu[i].prod);
604 else
605 gk20a_writel(g, gp10b_blcg_pmu[i].addr,
606 gp10b_blcg_pmu[i].disable);
607 }
608}
609
610void gp10b_blcg_xbar_load_gating_prod(struct gk20a *g,
611 bool prod)
612{
613 u32 i;
614 u32 size = sizeof(gp10b_blcg_xbar) / sizeof(struct gating_desc);
615 for (i = 0; i < size; i++) {
616 if (prod)
617 gk20a_writel(g, gp10b_blcg_xbar[i].addr,
618 gp10b_blcg_xbar[i].prod);
619 else
620 gk20a_writel(g, gp10b_blcg_xbar[i].addr,
621 gp10b_blcg_xbar[i].disable);
622 }
623}
624
625void gr_gp10b_pg_gr_load_gating_prod(struct gk20a *g,
626 bool prod)
627{
628 u32 i;
629 u32 size = sizeof(gp10b_pg_gr) / sizeof(struct gating_desc);
630 for (i = 0; i < size; i++) {
631 if (prod)
632 gk20a_writel(g, gp10b_pg_gr[i].addr,
633 gp10b_pg_gr[i].prod);
634 else
635 gk20a_writel(g, gp10b_pg_gr[i].addr,
636 gp10b_pg_gr[i].disable);
637 }
638}
639
640#endif /* __gp10b_gating_reglist_h__ */
diff --git a/drivers/gpu/nvgpu/gp10b/gp10b_gating_reglist.h b/drivers/gpu/nvgpu/gp10b/gp10b_gating_reglist.h
new file mode 100644
index 00000000..e4080def
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gp10b_gating_reglist.h
@@ -0,0 +1,93 @@
1/*
2 * Copyright (c) 2015-2016, 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 "gk20a/gk20a.h"
18
19void gp10b_slcg_bus_load_gating_prod(struct gk20a *g,
20 bool prod);
21
22void gp10b_slcg_ce2_load_gating_prod(struct gk20a *g,
23 bool prod);
24
25void gp10b_slcg_chiplet_load_gating_prod(struct gk20a *g,
26 bool prod);
27
28void gp10b_slcg_ctxsw_firmware_load_gating_prod(struct gk20a *g,
29 bool prod);
30
31void gp10b_slcg_fb_load_gating_prod(struct gk20a *g,
32 bool prod);
33
34void gp10b_slcg_fifo_load_gating_prod(struct gk20a *g,
35 bool prod);
36
37void gr_gp10b_slcg_gr_load_gating_prod(struct gk20a *g,
38 bool prod);
39
40void ltc_gp10b_slcg_ltc_load_gating_prod(struct gk20a *g,
41 bool prod);
42
43void gp10b_slcg_perf_load_gating_prod(struct gk20a *g,
44 bool prod);
45
46void gp10b_slcg_priring_load_gating_prod(struct gk20a *g,
47 bool prod);
48
49void gp10b_slcg_pwr_csb_load_gating_prod(struct gk20a *g,
50 bool prod);
51
52void gp10b_slcg_pmu_load_gating_prod(struct gk20a *g,
53 bool prod);
54
55void gp10b_slcg_therm_load_gating_prod(struct gk20a *g,
56 bool prod);
57
58void gp10b_slcg_xbar_load_gating_prod(struct gk20a *g,
59 bool prod);
60
61void gp10b_blcg_bus_load_gating_prod(struct gk20a *g,
62 bool prod);
63
64void gp10b_blcg_ce_load_gating_prod(struct gk20a *g,
65 bool prod);
66
67void gp10b_blcg_ctxsw_firmware_load_gating_prod(struct gk20a *g,
68 bool prod);
69
70void gp10b_blcg_fb_load_gating_prod(struct gk20a *g,
71 bool prod);
72
73void gp10b_blcg_fifo_load_gating_prod(struct gk20a *g,
74 bool prod);
75
76void gp10b_blcg_gr_load_gating_prod(struct gk20a *g,
77 bool prod);
78
79void gp10b_blcg_ltc_load_gating_prod(struct gk20a *g,
80 bool prod);
81
82void gp10b_blcg_pwr_csb_load_gating_prod(struct gk20a *g,
83 bool prod);
84
85void gp10b_blcg_pmu_load_gating_prod(struct gk20a *g,
86 bool prod);
87
88void gp10b_blcg_xbar_load_gating_prod(struct gk20a *g,
89 bool prod);
90
91void gr_gp10b_pg_gr_load_gating_prod(struct gk20a *g,
92 bool prod);
93
diff --git a/drivers/gpu/nvgpu/gp10b/gp10b_sysfs.c b/drivers/gpu/nvgpu/gp10b/gp10b_sysfs.c
new file mode 100644
index 00000000..5035bb99
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gp10b_sysfs.c
@@ -0,0 +1,64 @@
1/*
2 * GP10B specific sysfs files
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/platform_device.h>
17
18#include "gk20a/gk20a.h"
19#include "gp10b_sysfs.h"
20
21#define ROOTRW (S_IRWXU|S_IRGRP|S_IROTH)
22
23static ssize_t ecc_enable_store(struct device *dev,
24 struct device_attribute *attr, const char *buf, size_t count)
25{
26 struct gk20a *g = get_gk20a(dev);
27 u32 ecc_mask;
28 u32 err = 0;
29
30 err = sscanf(buf, "%d", &ecc_mask);
31 if (err == 1) {
32 err = g->ops.pmu.send_lrf_tex_ltc_dram_overide_en_dis_cmd
33 (g, ecc_mask);
34 if (err)
35 dev_err(dev, "ECC override did not happen\n");
36 } else
37 return -EINVAL;
38 return count;
39}
40
41static ssize_t ecc_enable_read(struct device *dev,
42 struct device_attribute *attr, char *buf)
43{
44 struct gk20a *g = get_gk20a(dev);
45
46 return sprintf(buf, "ecc override =0x%x\n",
47 g->ops.gr.get_lrf_tex_ltc_dram_override(g));
48}
49
50static DEVICE_ATTR(ecc_enable, ROOTRW, ecc_enable_read, ecc_enable_store);
51
52void gp10b_create_sysfs(struct device *dev)
53{
54 int error = 0;
55
56 error |= device_create_file(dev, &dev_attr_ecc_enable);
57 if (error)
58 dev_err(dev, "Failed to create sysfs attributes!\n");
59}
60
61void gp10b_remove_sysfs(struct device *dev)
62{
63 device_remove_file(dev, &dev_attr_ecc_enable);
64}
diff --git a/drivers/gpu/nvgpu/gp10b/gp10b_sysfs.h b/drivers/gpu/nvgpu/gp10b/gp10b_sysfs.h
new file mode 100644
index 00000000..786a3bb0
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gp10b_sysfs.h
@@ -0,0 +1,29 @@
1/*
2 * GP10B specific sysfs files
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _GP10B_SYSFS_H_
17#define _GP10B_SYSFS_H_
18
19#include <linux/version.h>
20
21/*ECC Fuse*/
22#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
23#define FUSE_OPT_ECC_EN 0x358
24#endif
25
26void gp10b_create_sysfs(struct device *dev);
27void gp10b_remove_sysfs(struct device *dev);
28
29#endif /*_GP10B_SYSFS_H_*/
diff --git a/drivers/gpu/nvgpu/gp10b/gr_ctx_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_ctx_gp10b.c
new file mode 100644
index 00000000..2bb4a313
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gr_ctx_gp10b.c
@@ -0,0 +1,73 @@
1/*
2 * drivers/video/tegra/host/gp10b/gr_ctx_gp10b.c
3 *
4 * GM20B Graphics Context
5 *
6 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22#include "gk20a/gk20a.h"
23#include "gr_ctx_gp10b.h"
24
25static int gr_gp10b_get_netlist_name(struct gk20a *g, int index, char *name)
26{
27 switch (index) {
28#ifdef GP10B_NETLIST_IMAGE_FW_NAME
29 case NETLIST_FINAL:
30 sprintf(name, GP10B_NETLIST_IMAGE_FW_NAME);
31 return 0;
32#endif
33#ifdef GK20A_NETLIST_IMAGE_A
34 case NETLIST_SLOT_A:
35 sprintf(name, GK20A_NETLIST_IMAGE_A);
36 return 0;
37#endif
38#ifdef GK20A_NETLIST_IMAGE_B
39 case NETLIST_SLOT_B:
40 sprintf(name, GK20A_NETLIST_IMAGE_B);
41 return 0;
42#endif
43#ifdef GK20A_NETLIST_IMAGE_C
44 case NETLIST_SLOT_C:
45 sprintf(name, GK20A_NETLIST_IMAGE_C);
46 return 0;
47#endif
48#ifdef GK20A_NETLIST_IMAGE_D
49 case NETLIST_SLOT_D:
50 sprintf(name, GK20A_NETLIST_IMAGE_D);
51 return 0;
52#endif
53 default:
54 return -1;
55 }
56
57 return -1;
58}
59
60static bool gr_gp10b_is_firmware_defined(void)
61{
62#ifdef GP10B_NETLIST_IMAGE_FW_NAME
63 return true;
64#else
65 return false;
66#endif
67}
68
69void gp10b_init_gr_ctx(struct gpu_ops *gops) {
70 gops->gr_ctx.get_netlist_name = gr_gp10b_get_netlist_name;
71 gops->gr_ctx.is_fw_defined = gr_gp10b_is_firmware_defined;
72 gops->gr_ctx.use_dma_for_fw_bootstrap = true;
73}
diff --git a/drivers/gpu/nvgpu/gp10b/gr_ctx_gp10b.h b/drivers/gpu/nvgpu/gp10b/gr_ctx_gp10b.h
new file mode 100644
index 00000000..b5c76d24
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gr_ctx_gp10b.h
@@ -0,0 +1,28 @@
1/*
2 * GP10B Graphics Context
3 *
4 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef __GR_CTX_GM10B_H__
19#define __GR_CTX_GM10B_H__
20
21#include "gk20a/gr_ctx_gk20a.h"
22
23/* production netlist, one and only one from below */
24#define GP10B_NETLIST_IMAGE_FW_NAME GK20A_NETLIST_IMAGE_A
25
26void gp10b_init_gr_ctx(struct gpu_ops *gops);
27
28#endif /*__GR_CTX_GP10B_H__*/
diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
new file mode 100644
index 00000000..9de7d675
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
@@ -0,0 +1,2257 @@
1/*
2 * GP10B GPU GR
3 *
4 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include "gk20a/gk20a.h" /* FERMI and MAXWELL classes defined here */
17#include <linux/clk.h>
18#include <linux/delay.h>
19#include <linux/tegra-fuse.h>
20#include <linux/version.h>
21
22#include <dt-bindings/soc/gm20b-fuse.h>
23#include <dt-bindings/soc/gp10b-fuse.h>
24
25#include "gk20a/gr_gk20a.h"
26#include "gk20a/semaphore_gk20a.h"
27#include "gk20a/dbg_gpu_gk20a.h"
28
29#include "gm20b/gr_gm20b.h" /* for MAXWELL classes */
30#include "gp10b/gr_gp10b.h"
31#include "hw_gr_gp10b.h"
32#include "hw_fifo_gp10b.h"
33#include "hw_ctxsw_prog_gp10b.h"
34#include "hw_mc_gp10b.h"
35#include "gp10b_sysfs.h"
36#include <linux/vmalloc.h>
37
38#define NVGPU_GFXP_WFI_TIMEOUT_US 100LL
39
40static bool gr_gp10b_is_valid_class(struct gk20a *g, u32 class_num)
41{
42 bool valid = false;
43
44 switch (class_num) {
45 case PASCAL_COMPUTE_A:
46 case PASCAL_A:
47 case PASCAL_DMA_COPY_A:
48 valid = true;
49 break;
50
51 case MAXWELL_COMPUTE_B:
52 case MAXWELL_B:
53 case FERMI_TWOD_A:
54 case KEPLER_DMA_COPY_A:
55 case MAXWELL_DMA_COPY_A:
56 valid = true;
57 break;
58
59 default:
60 break;
61 }
62 gk20a_dbg_info("class=0x%x valid=%d", class_num, valid);
63 return valid;
64}
65
66static void gr_gp10b_sm_lrf_ecc_overcount_war(int single_err,
67 u32 sed_status,
68 u32 ded_status,
69 u32 *count_to_adjust,
70 u32 opposite_count)
71{
72 u32 over_count = 0;
73
74 sed_status >>= gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp0_b();
75 ded_status >>= gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp0_b();
76
77 /* One overcount for each partition on which a SBE occurred but not a
78 DBE (or vice-versa) */
79 if (single_err) {
80 over_count =
81 hweight32(sed_status & ~ded_status);
82 } else {
83 over_count =
84 hweight32(ded_status & ~sed_status);
85 }
86
87 /* If both a SBE and a DBE occur on the same partition, then we have an
88 overcount for the subpartition if the opposite error counts are
89 zero. */
90 if ((sed_status & ded_status) && (opposite_count == 0)) {
91 over_count +=
92 hweight32(sed_status & ded_status);
93 }
94
95 if (*count_to_adjust > over_count)
96 *count_to_adjust -= over_count;
97 else
98 *count_to_adjust = 0;
99}
100
101static int gr_gp10b_handle_sm_exception(struct gk20a *g, u32 gpc, u32 tpc,
102 bool *post_event, struct channel_gk20a *fault_ch,
103 u32 *hww_global_esr)
104{
105 int ret = 0;
106 u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
107 u32 tpc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_TPC_IN_GPC_STRIDE);
108 u32 offset = gpc_stride * gpc + tpc_in_gpc_stride * tpc;
109 u32 lrf_ecc_status, lrf_ecc_sed_status, lrf_ecc_ded_status;
110 u32 lrf_single_count_delta, lrf_double_count_delta;
111 u32 shm_ecc_status;
112
113 gr_gk20a_handle_sm_exception(g, gpc, tpc, post_event, fault_ch, hww_global_esr);
114
115 /* Check for LRF ECC errors. */
116 lrf_ecc_status = gk20a_readl(g,
117 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_r() + offset);
118 lrf_ecc_sed_status = lrf_ecc_status &
119 (gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp0_pending_f() |
120 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp1_pending_f() |
121 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp2_pending_f() |
122 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp3_pending_f());
123 lrf_ecc_ded_status = lrf_ecc_status &
124 (gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp0_pending_f() |
125 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp1_pending_f() |
126 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp2_pending_f() |
127 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp3_pending_f());
128 lrf_single_count_delta =
129 gk20a_readl(g,
130 gr_pri_gpc0_tpc0_sm_lrf_ecc_single_err_count_r() +
131 offset);
132 lrf_double_count_delta =
133 gk20a_readl(g,
134 gr_pri_gpc0_tpc0_sm_lrf_ecc_double_err_count_r() +
135 offset);
136 gk20a_writel(g,
137 gr_pri_gpc0_tpc0_sm_lrf_ecc_single_err_count_r() + offset,
138 0);
139 gk20a_writel(g,
140 gr_pri_gpc0_tpc0_sm_lrf_ecc_double_err_count_r() + offset,
141 0);
142 if (lrf_ecc_sed_status) {
143 gk20a_dbg(gpu_dbg_fn | gpu_dbg_intr,
144 "Single bit error detected in SM LRF!");
145
146 gr_gp10b_sm_lrf_ecc_overcount_war(1,
147 lrf_ecc_sed_status,
148 lrf_ecc_ded_status,
149 &lrf_single_count_delta,
150 lrf_double_count_delta);
151 g->gr.t18x.ecc_stats.sm_lrf_single_err_count.counters[tpc] +=
152 lrf_single_count_delta;
153 }
154 if (lrf_ecc_ded_status) {
155 gk20a_dbg(gpu_dbg_fn | gpu_dbg_intr,
156 "Double bit error detected in SM LRF!");
157
158 gr_gp10b_sm_lrf_ecc_overcount_war(0,
159 lrf_ecc_sed_status,
160 lrf_ecc_ded_status,
161 &lrf_double_count_delta,
162 lrf_single_count_delta);
163 g->gr.t18x.ecc_stats.sm_lrf_double_err_count.counters[tpc] +=
164 lrf_double_count_delta;
165 }
166 gk20a_writel(g, gr_pri_gpc0_tpc0_sm_lrf_ecc_status_r() + offset,
167 lrf_ecc_status);
168
169 /* Check for SHM ECC errors. */
170 shm_ecc_status = gk20a_readl(g,
171 gr_pri_gpc0_tpc0_sm_shm_ecc_status_r() + offset);
172 if ((shm_ecc_status &
173 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_corrected_shm0_pending_f()) ||
174 (shm_ecc_status &
175 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_corrected_shm1_pending_f()) ||
176 (shm_ecc_status &
177 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_detected_shm0_pending_f()) ||
178 (shm_ecc_status &
179 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_detected_shm1_pending_f()) ) {
180 u32 ecc_stats_reg_val;
181
182 gk20a_dbg(gpu_dbg_fn | gpu_dbg_intr,
183 "Single bit error detected in SM SHM!");
184
185 ecc_stats_reg_val =
186 gk20a_readl(g,
187 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_r() + offset);
188 g->gr.t18x.ecc_stats.sm_shm_sec_count.counters[tpc] +=
189 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_corrected_v(ecc_stats_reg_val);
190 g->gr.t18x.ecc_stats.sm_shm_sed_count.counters[tpc] +=
191 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_detected_v(ecc_stats_reg_val);
192 ecc_stats_reg_val &= ~(gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_corrected_m() |
193 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_detected_m());
194 gk20a_writel(g,
195 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_r() + offset,
196 ecc_stats_reg_val);
197 }
198 if ( (shm_ecc_status &
199 gr_pri_gpc0_tpc0_sm_shm_ecc_status_double_err_detected_shm0_pending_f()) ||
200 (shm_ecc_status &
201 gr_pri_gpc0_tpc0_sm_shm_ecc_status_double_err_detected_shm1_pending_f()) ) {
202 u32 ecc_stats_reg_val;
203
204 gk20a_dbg(gpu_dbg_fn | gpu_dbg_intr,
205 "Double bit error detected in SM SHM!");
206
207 ecc_stats_reg_val =
208 gk20a_readl(g,
209 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_r() + offset);
210 g->gr.t18x.ecc_stats.sm_shm_ded_count.counters[tpc] +=
211 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_double_detected_v(ecc_stats_reg_val);
212 ecc_stats_reg_val &= ~(gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_double_detected_m());
213 gk20a_writel(g,
214 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_r() + offset,
215 ecc_stats_reg_val);
216 }
217 gk20a_writel(g, gr_pri_gpc0_tpc0_sm_shm_ecc_status_r() + offset,
218 shm_ecc_status);
219
220
221 return ret;
222}
223
224static int gr_gp10b_handle_tex_exception(struct gk20a *g, u32 gpc, u32 tpc,
225 bool *post_event)
226{
227 int ret = 0;
228 u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
229 u32 tpc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_TPC_IN_GPC_STRIDE);
230 u32 offset = gpc_stride * gpc + tpc_in_gpc_stride * tpc;
231 u32 esr;
232 u32 ecc_stats_reg_val;
233
234 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, "");
235
236 esr = gk20a_readl(g,
237 gr_gpc0_tpc0_tex_m_hww_esr_r() + offset);
238 gk20a_dbg(gpu_dbg_intr | gpu_dbg_gpu_dbg, "0x%08x", esr);
239
240 if (esr & gr_gpc0_tpc0_tex_m_hww_esr_ecc_sec_pending_f()) {
241 gk20a_dbg(gpu_dbg_fn | gpu_dbg_intr,
242 "Single bit error detected in TEX!");
243
244 /* Pipe 0 counters */
245 gk20a_writel(g,
246 gr_pri_gpc0_tpc0_tex_m_routing_r() + offset,
247 gr_pri_gpc0_tpc0_tex_m_routing_sel_pipe0_f());
248
249 ecc_stats_reg_val = gk20a_readl(g,
250 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_r() + offset);
251 g->gr.t18x.ecc_stats.tex_total_sec_pipe0_count.counters[tpc] +=
252 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_sec_v(ecc_stats_reg_val);
253 ecc_stats_reg_val &= ~gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_sec_m();
254 gk20a_writel(g,
255 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_r() + offset,
256 ecc_stats_reg_val);
257
258 ecc_stats_reg_val = gk20a_readl(g,
259 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_r() + offset);
260 g->gr.t18x.ecc_stats.tex_unique_sec_pipe0_count.counters[tpc] +=
261 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_sec_v(ecc_stats_reg_val);
262 ecc_stats_reg_val &= ~gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_sec_m();
263 gk20a_writel(g,
264 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_r() + offset,
265 ecc_stats_reg_val);
266
267
268 /* Pipe 1 counters */
269 gk20a_writel(g,
270 gr_pri_gpc0_tpc0_tex_m_routing_r() + offset,
271 gr_pri_gpc0_tpc0_tex_m_routing_sel_pipe1_f());
272
273 ecc_stats_reg_val = gk20a_readl(g,
274 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_r() + offset);
275 g->gr.t18x.ecc_stats.tex_total_sec_pipe1_count.counters[tpc] +=
276 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_sec_v(ecc_stats_reg_val);
277 ecc_stats_reg_val &= ~gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_sec_m();
278 gk20a_writel(g,
279 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_r() + offset,
280 ecc_stats_reg_val);
281
282 ecc_stats_reg_val = gk20a_readl(g,
283 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_r() + offset);
284 g->gr.t18x.ecc_stats.tex_unique_sec_pipe1_count.counters[tpc] +=
285 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_sec_v(ecc_stats_reg_val);
286 ecc_stats_reg_val &= ~gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_sec_m();
287 gk20a_writel(g,
288 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_r() + offset,
289 ecc_stats_reg_val);
290
291
292 gk20a_writel(g,
293 gr_pri_gpc0_tpc0_tex_m_routing_r() + offset,
294 gr_pri_gpc0_tpc0_tex_m_routing_sel_default_f());
295 }
296 if (esr & gr_gpc0_tpc0_tex_m_hww_esr_ecc_ded_pending_f()) {
297 gk20a_dbg(gpu_dbg_fn | gpu_dbg_intr,
298 "Double bit error detected in TEX!");
299
300 /* Pipe 0 counters */
301 gk20a_writel(g,
302 gr_pri_gpc0_tpc0_tex_m_routing_r() + offset,
303 gr_pri_gpc0_tpc0_tex_m_routing_sel_pipe0_f());
304
305 ecc_stats_reg_val = gk20a_readl(g,
306 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_r() + offset);
307 g->gr.t18x.ecc_stats.tex_total_ded_pipe0_count.counters[tpc] +=
308 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_ded_v(ecc_stats_reg_val);
309 ecc_stats_reg_val &= ~gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_ded_m();
310 gk20a_writel(g,
311 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_r() + offset,
312 ecc_stats_reg_val);
313
314 ecc_stats_reg_val = gk20a_readl(g,
315 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_r() + offset);
316 g->gr.t18x.ecc_stats.tex_unique_ded_pipe0_count.counters[tpc] +=
317 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_ded_v(ecc_stats_reg_val);
318 ecc_stats_reg_val &= ~gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_ded_m();
319 gk20a_writel(g,
320 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_r() + offset,
321 ecc_stats_reg_val);
322
323
324 /* Pipe 1 counters */
325 gk20a_writel(g,
326 gr_pri_gpc0_tpc0_tex_m_routing_r() + offset,
327 gr_pri_gpc0_tpc0_tex_m_routing_sel_pipe1_f());
328
329 ecc_stats_reg_val = gk20a_readl(g,
330 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_r() + offset);
331 g->gr.t18x.ecc_stats.tex_total_ded_pipe1_count.counters[tpc] +=
332 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_ded_v(ecc_stats_reg_val);
333 ecc_stats_reg_val &= ~gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_ded_m();
334 gk20a_writel(g,
335 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_r() + offset,
336 ecc_stats_reg_val);
337
338 ecc_stats_reg_val = gk20a_readl(g,
339 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_r() + offset);
340 g->gr.t18x.ecc_stats.tex_unique_ded_pipe1_count.counters[tpc] +=
341 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_ded_v(ecc_stats_reg_val);
342 ecc_stats_reg_val &= ~gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_ded_m();
343 gk20a_writel(g,
344 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_r() + offset,
345 ecc_stats_reg_val);
346
347
348 gk20a_writel(g,
349 gr_pri_gpc0_tpc0_tex_m_routing_r() + offset,
350 gr_pri_gpc0_tpc0_tex_m_routing_sel_default_f());
351 }
352
353 gk20a_writel(g,
354 gr_gpc0_tpc0_tex_m_hww_esr_r() + offset,
355 esr | gr_gpc0_tpc0_tex_m_hww_esr_reset_active_f());
356
357 return ret;
358}
359
360static int gr_gp10b_commit_global_cb_manager(struct gk20a *g,
361 struct channel_gk20a *c, bool patch)
362{
363 struct gr_gk20a *gr = &g->gr;
364 struct channel_ctx_gk20a *ch_ctx = &c->ch_ctx;
365 struct gr_ctx_desc *gr_ctx = ch_ctx->gr_ctx;
366 u32 attrib_offset_in_chunk = 0;
367 u32 alpha_offset_in_chunk = 0;
368 u32 pd_ab_max_output;
369 u32 gpc_index, ppc_index;
370 u32 temp, temp2;
371 u32 cbm_cfg_size_beta, cbm_cfg_size_alpha, cbm_cfg_size_steadystate;
372 u32 attrib_size_in_chunk, cb_attrib_cache_size_init;
373 u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
374 u32 ppc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_PPC_IN_GPC_STRIDE);
375 u32 num_pes_per_gpc = nvgpu_get_litter_value(g, GPU_LIT_NUM_PES_PER_GPC);
376
377 gk20a_dbg_fn("");
378
379 if (gr_ctx->graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) {
380 attrib_size_in_chunk = gr->attrib_cb_default_size +
381 (gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v() -
382 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v());
383 cb_attrib_cache_size_init = gr->attrib_cb_default_size +
384 (gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v() -
385 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v());
386 } else {
387 attrib_size_in_chunk = gr->attrib_cb_size;
388 cb_attrib_cache_size_init = gr->attrib_cb_default_size;
389 }
390
391 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_ds_tga_constraintlogic_beta_r(),
392 gr->attrib_cb_default_size, patch);
393 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_ds_tga_constraintlogic_alpha_r(),
394 gr->alpha_cb_default_size, patch);
395
396 pd_ab_max_output = (gr->alpha_cb_default_size *
397 gr_gpc0_ppc0_cbm_beta_cb_size_v_granularity_v()) /
398 gr_pd_ab_dist_cfg1_max_output_granularity_v();
399
400 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_pd_ab_dist_cfg1_r(),
401 gr_pd_ab_dist_cfg1_max_output_f(pd_ab_max_output) |
402 gr_pd_ab_dist_cfg1_max_batches_init_f(), patch);
403
404 attrib_offset_in_chunk = alpha_offset_in_chunk +
405 gr->tpc_count * gr->alpha_cb_size;
406
407 for (gpc_index = 0; gpc_index < gr->gpc_count; gpc_index++) {
408 temp = gpc_stride * gpc_index;
409 temp2 = num_pes_per_gpc * gpc_index;
410 for (ppc_index = 0; ppc_index < gr->gpc_ppc_count[gpc_index];
411 ppc_index++) {
412 cbm_cfg_size_beta = cb_attrib_cache_size_init *
413 gr->pes_tpc_count[ppc_index][gpc_index];
414 cbm_cfg_size_alpha = gr->alpha_cb_default_size *
415 gr->pes_tpc_count[ppc_index][gpc_index];
416 cbm_cfg_size_steadystate = gr->attrib_cb_default_size *
417 gr->pes_tpc_count[ppc_index][gpc_index];
418
419 gr_gk20a_ctx_patch_write(g, ch_ctx,
420 gr_gpc0_ppc0_cbm_beta_cb_size_r() + temp +
421 ppc_in_gpc_stride * ppc_index,
422 cbm_cfg_size_beta, patch);
423
424 gr_gk20a_ctx_patch_write(g, ch_ctx,
425 gr_gpc0_ppc0_cbm_beta_cb_offset_r() + temp +
426 ppc_in_gpc_stride * ppc_index,
427 attrib_offset_in_chunk, patch);
428
429 gr_gk20a_ctx_patch_write(g, ch_ctx,
430 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_r() + temp +
431 ppc_in_gpc_stride * ppc_index,
432 cbm_cfg_size_steadystate,
433 patch);
434
435 attrib_offset_in_chunk += attrib_size_in_chunk *
436 gr->pes_tpc_count[ppc_index][gpc_index];
437
438 gr_gk20a_ctx_patch_write(g, ch_ctx,
439 gr_gpc0_ppc0_cbm_alpha_cb_size_r() + temp +
440 ppc_in_gpc_stride * ppc_index,
441 cbm_cfg_size_alpha, patch);
442
443 gr_gk20a_ctx_patch_write(g, ch_ctx,
444 gr_gpc0_ppc0_cbm_alpha_cb_offset_r() + temp +
445 ppc_in_gpc_stride * ppc_index,
446 alpha_offset_in_chunk, patch);
447
448 alpha_offset_in_chunk += gr->alpha_cb_size *
449 gr->pes_tpc_count[ppc_index][gpc_index];
450
451 gr_gk20a_ctx_patch_write(g, ch_ctx,
452 gr_gpcs_swdx_tc_beta_cb_size_r(ppc_index + temp2),
453 gr_gpcs_swdx_tc_beta_cb_size_v_f(cbm_cfg_size_steadystate),
454 patch);
455 }
456 }
457
458 return 0;
459}
460
461static void gr_gp10b_commit_global_pagepool(struct gk20a *g,
462 struct channel_ctx_gk20a *ch_ctx,
463 u64 addr, u32 size, bool patch)
464{
465 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_scc_pagepool_base_r(),
466 gr_scc_pagepool_base_addr_39_8_f(addr), patch);
467
468 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_scc_pagepool_r(),
469 gr_scc_pagepool_total_pages_f(size) |
470 gr_scc_pagepool_valid_true_f(), patch);
471
472 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_gpcs_gcc_pagepool_base_r(),
473 gr_gpcs_gcc_pagepool_base_addr_39_8_f(addr), patch);
474
475 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_gpcs_gcc_pagepool_r(),
476 gr_gpcs_gcc_pagepool_total_pages_f(size), patch);
477}
478
479static int gr_gp10b_add_zbc_color(struct gk20a *g, struct gr_gk20a *gr,
480 struct zbc_entry *color_val, u32 index)
481{
482 u32 i;
483 u32 zbc_c;
484
485 /* update l2 table */
486 g->ops.ltc.set_zbc_color_entry(g, color_val, index);
487
488 /* update ds table */
489 gk20a_writel(g, gr_ds_zbc_color_r_r(),
490 gr_ds_zbc_color_r_val_f(color_val->color_ds[0]));
491 gk20a_writel(g, gr_ds_zbc_color_g_r(),
492 gr_ds_zbc_color_g_val_f(color_val->color_ds[1]));
493 gk20a_writel(g, gr_ds_zbc_color_b_r(),
494 gr_ds_zbc_color_b_val_f(color_val->color_ds[2]));
495 gk20a_writel(g, gr_ds_zbc_color_a_r(),
496 gr_ds_zbc_color_a_val_f(color_val->color_ds[3]));
497
498 gk20a_writel(g, gr_ds_zbc_color_fmt_r(),
499 gr_ds_zbc_color_fmt_val_f(color_val->format));
500
501 gk20a_writel(g, gr_ds_zbc_tbl_index_r(),
502 gr_ds_zbc_tbl_index_val_f(index + GK20A_STARTOF_ZBC_TABLE));
503
504 /* trigger the write */
505 gk20a_writel(g, gr_ds_zbc_tbl_ld_r(),
506 gr_ds_zbc_tbl_ld_select_c_f() |
507 gr_ds_zbc_tbl_ld_action_write_f() |
508 gr_ds_zbc_tbl_ld_trigger_active_f());
509
510 /* update local copy */
511 for (i = 0; i < GK20A_ZBC_COLOR_VALUE_SIZE; i++) {
512 gr->zbc_col_tbl[index].color_l2[i] = color_val->color_l2[i];
513 gr->zbc_col_tbl[index].color_ds[i] = color_val->color_ds[i];
514 }
515 gr->zbc_col_tbl[index].format = color_val->format;
516 gr->zbc_col_tbl[index].ref_cnt++;
517
518 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_color_r_r(index),
519 color_val->color_ds[0]);
520 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_color_g_r(index),
521 color_val->color_ds[1]);
522 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_color_b_r(index),
523 color_val->color_ds[2]);
524 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_color_a_r(index),
525 color_val->color_ds[3]);
526 zbc_c = gk20a_readl(g, gr_gpcs_swdx_dss_zbc_c_01_to_04_format_r() + (index & ~3));
527 zbc_c &= ~(0x7f << ((index % 4) * 7));
528 zbc_c |= color_val->format << ((index % 4) * 7);
529 gk20a_writel_check(g, gr_gpcs_swdx_dss_zbc_c_01_to_04_format_r() + (index & ~3), zbc_c);
530
531 return 0;
532}
533
534static int gr_gp10b_add_zbc_depth(struct gk20a *g, struct gr_gk20a *gr,
535 struct zbc_entry *depth_val, u32 index)
536{
537 u32 zbc_z;
538
539 /* update l2 table */
540 g->ops.ltc.set_zbc_depth_entry(g, depth_val, index);
541
542 /* update ds table */
543 gk20a_writel(g, gr_ds_zbc_z_r(),
544 gr_ds_zbc_z_val_f(depth_val->depth));
545
546 gk20a_writel(g, gr_ds_zbc_z_fmt_r(),
547 gr_ds_zbc_z_fmt_val_f(depth_val->format));
548
549 gk20a_writel(g, gr_ds_zbc_tbl_index_r(),
550 gr_ds_zbc_tbl_index_val_f(index + GK20A_STARTOF_ZBC_TABLE));
551
552 /* trigger the write */
553 gk20a_writel(g, gr_ds_zbc_tbl_ld_r(),
554 gr_ds_zbc_tbl_ld_select_z_f() |
555 gr_ds_zbc_tbl_ld_action_write_f() |
556 gr_ds_zbc_tbl_ld_trigger_active_f());
557
558 /* update local copy */
559 gr->zbc_dep_tbl[index].depth = depth_val->depth;
560 gr->zbc_dep_tbl[index].format = depth_val->format;
561 gr->zbc_dep_tbl[index].ref_cnt++;
562
563 gk20a_writel(g, gr_gpcs_swdx_dss_zbc_z_r(index), depth_val->depth);
564 zbc_z = gk20a_readl(g, gr_gpcs_swdx_dss_zbc_z_01_to_04_format_r() + (index & ~3));
565 zbc_z &= ~(0x7f << (index % 4) * 7);
566 zbc_z |= depth_val->format << (index % 4) * 7;
567 gk20a_writel(g, gr_gpcs_swdx_dss_zbc_z_01_to_04_format_r() + (index & ~3), zbc_z);
568
569 return 0;
570}
571
572static u32 gr_gp10b_pagepool_default_size(struct gk20a *g)
573{
574 return gr_scc_pagepool_total_pages_hwmax_value_v();
575}
576
577static int gr_gp10b_calc_global_ctx_buffer_size(struct gk20a *g)
578{
579 struct gr_gk20a *gr = &g->gr;
580 int size;
581
582 gr->attrib_cb_size = gr->attrib_cb_default_size;
583 gr->alpha_cb_size = gr->alpha_cb_default_size;
584
585 gr->attrib_cb_size = min(gr->attrib_cb_size,
586 gr_gpc0_ppc0_cbm_beta_cb_size_v_f(~0) / g->gr.tpc_count);
587 gr->alpha_cb_size = min(gr->alpha_cb_size,
588 gr_gpc0_ppc0_cbm_alpha_cb_size_v_f(~0) / g->gr.tpc_count);
589
590 size = gr->attrib_cb_size *
591 gr_gpc0_ppc0_cbm_beta_cb_size_v_granularity_v() *
592 gr->max_tpc_count;
593
594 size += gr->alpha_cb_size *
595 gr_gpc0_ppc0_cbm_alpha_cb_size_v_granularity_v() *
596 gr->max_tpc_count;
597
598 size = ALIGN(size, 128);
599
600 return size;
601}
602
603static void gr_gp10b_set_go_idle_timeout(struct gk20a *g, u32 data)
604{
605 gk20a_writel(g, gr_fe_go_idle_timeout_r(), data);
606}
607
608static void gr_gp10b_set_coalesce_buffer_size(struct gk20a *g, u32 data)
609{
610 u32 val;
611
612 gk20a_dbg_fn("");
613
614 val = gk20a_readl(g, gr_gpcs_tc_debug0_r());
615 val = set_field(val, gr_gpcs_tc_debug0_limit_coalesce_buffer_size_m(),
616 gr_gpcs_tc_debug0_limit_coalesce_buffer_size_f(data));
617 gk20a_writel(g, gr_gpcs_tc_debug0_r(), val);
618
619 gk20a_dbg_fn("done");
620}
621
622static int gr_gp10b_handle_sw_method(struct gk20a *g, u32 addr,
623 u32 class_num, u32 offset, u32 data)
624{
625 gk20a_dbg_fn("");
626
627 if (class_num == PASCAL_COMPUTE_A) {
628 switch (offset << 2) {
629 case NVC0C0_SET_SHADER_EXCEPTIONS:
630 gk20a_gr_set_shader_exceptions(g, data);
631 break;
632 default:
633 goto fail;
634 }
635 }
636
637 if (class_num == PASCAL_A) {
638 switch (offset << 2) {
639 case NVC097_SET_SHADER_EXCEPTIONS:
640 gk20a_gr_set_shader_exceptions(g, data);
641 break;
642 case NVC097_SET_CIRCULAR_BUFFER_SIZE:
643 g->ops.gr.set_circular_buffer_size(g, data);
644 break;
645 case NVC097_SET_ALPHA_CIRCULAR_BUFFER_SIZE:
646 g->ops.gr.set_alpha_circular_buffer_size(g, data);
647 break;
648 case NVC097_SET_GO_IDLE_TIMEOUT:
649 gr_gp10b_set_go_idle_timeout(g, data);
650 break;
651 case NVC097_SET_COALESCE_BUFFER_SIZE:
652 gr_gp10b_set_coalesce_buffer_size(g, data);
653 break;
654 default:
655 goto fail;
656 }
657 }
658 return 0;
659
660fail:
661 return -EINVAL;
662}
663
664static void gr_gp10b_cb_size_default(struct gk20a *g)
665{
666 struct gr_gk20a *gr = &g->gr;
667
668 if (!gr->attrib_cb_default_size)
669 gr->attrib_cb_default_size = 0x800;
670 gr->alpha_cb_default_size =
671 gr_gpc0_ppc0_cbm_alpha_cb_size_v_default_v();
672}
673
674static void gr_gp10b_set_alpha_circular_buffer_size(struct gk20a *g, u32 data)
675{
676 struct gr_gk20a *gr = &g->gr;
677 u32 gpc_index, ppc_index, stride, val;
678 u32 pd_ab_max_output;
679 u32 alpha_cb_size = data * 4;
680 u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
681 u32 ppc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_PPC_IN_GPC_STRIDE);
682
683 gk20a_dbg_fn("");
684
685 if (alpha_cb_size > gr->alpha_cb_size)
686 alpha_cb_size = gr->alpha_cb_size;
687
688 gk20a_writel(g, gr_ds_tga_constraintlogic_alpha_r(),
689 (gk20a_readl(g, gr_ds_tga_constraintlogic_alpha_r()) &
690 ~gr_ds_tga_constraintlogic_alpha_cbsize_f(~0)) |
691 gr_ds_tga_constraintlogic_alpha_cbsize_f(alpha_cb_size));
692
693 pd_ab_max_output = alpha_cb_size *
694 gr_gpc0_ppc0_cbm_alpha_cb_size_v_granularity_v() /
695 gr_pd_ab_dist_cfg1_max_output_granularity_v();
696
697 gk20a_writel(g, gr_pd_ab_dist_cfg1_r(),
698 gr_pd_ab_dist_cfg1_max_output_f(pd_ab_max_output) |
699 gr_pd_ab_dist_cfg1_max_batches_init_f());
700
701 for (gpc_index = 0; gpc_index < gr->gpc_count; gpc_index++) {
702 stride = gpc_stride * gpc_index;
703
704 for (ppc_index = 0; ppc_index < gr->gpc_ppc_count[gpc_index];
705 ppc_index++) {
706
707 val = gk20a_readl(g, gr_gpc0_ppc0_cbm_alpha_cb_size_r() +
708 stride +
709 ppc_in_gpc_stride * ppc_index);
710
711 val = set_field(val, gr_gpc0_ppc0_cbm_alpha_cb_size_v_m(),
712 gr_gpc0_ppc0_cbm_alpha_cb_size_v_f(alpha_cb_size *
713 gr->pes_tpc_count[ppc_index][gpc_index]));
714
715 gk20a_writel(g, gr_gpc0_ppc0_cbm_alpha_cb_size_r() +
716 stride +
717 ppc_in_gpc_stride * ppc_index, val);
718 }
719 }
720}
721
722static void gr_gp10b_set_circular_buffer_size(struct gk20a *g, u32 data)
723{
724 struct gr_gk20a *gr = &g->gr;
725 u32 gpc_index, ppc_index, stride, val;
726 u32 cb_size_steady = data * 4, cb_size;
727 u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
728 u32 ppc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_PPC_IN_GPC_STRIDE);
729
730 gk20a_dbg_fn("");
731
732 if (cb_size_steady > gr->attrib_cb_size)
733 cb_size_steady = gr->attrib_cb_size;
734 if (gk20a_readl(g, gr_gpc0_ppc0_cbm_beta_cb_size_r()) !=
735 gk20a_readl(g,
736 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_r())) {
737 cb_size = cb_size_steady +
738 (gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v() -
739 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v());
740 } else {
741 cb_size = cb_size_steady;
742 }
743
744 gk20a_writel(g, gr_ds_tga_constraintlogic_beta_r(),
745 (gk20a_readl(g, gr_ds_tga_constraintlogic_beta_r()) &
746 ~gr_ds_tga_constraintlogic_beta_cbsize_f(~0)) |
747 gr_ds_tga_constraintlogic_beta_cbsize_f(cb_size_steady));
748
749 for (gpc_index = 0; gpc_index < gr->gpc_count; gpc_index++) {
750 stride = gpc_stride * gpc_index;
751
752 for (ppc_index = 0; ppc_index < gr->gpc_ppc_count[gpc_index];
753 ppc_index++) {
754
755 val = gk20a_readl(g, gr_gpc0_ppc0_cbm_beta_cb_size_r() +
756 stride +
757 ppc_in_gpc_stride * ppc_index);
758
759 val = set_field(val,
760 gr_gpc0_ppc0_cbm_beta_cb_size_v_m(),
761 gr_gpc0_ppc0_cbm_beta_cb_size_v_f(cb_size *
762 gr->pes_tpc_count[ppc_index][gpc_index]));
763
764 gk20a_writel(g, gr_gpc0_ppc0_cbm_beta_cb_size_r() +
765 stride +
766 ppc_in_gpc_stride * ppc_index, val);
767
768 gk20a_writel(g, ppc_in_gpc_stride * ppc_index +
769 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_r() +
770 stride,
771 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_v_f(
772 cb_size_steady));
773
774 val = gk20a_readl(g, gr_gpcs_swdx_tc_beta_cb_size_r(
775 ppc_index + gpc_index));
776
777 val = set_field(val,
778 gr_gpcs_swdx_tc_beta_cb_size_v_m(),
779 gr_gpcs_swdx_tc_beta_cb_size_v_f(
780 cb_size_steady *
781 gr->gpc_ppc_count[gpc_index]));
782
783 gk20a_writel(g, gr_gpcs_swdx_tc_beta_cb_size_r(
784 ppc_index + gpc_index), val);
785 }
786 }
787}
788
789static int gr_gp10b_init_ctx_state(struct gk20a *g)
790{
791 struct fecs_method_op_gk20a op = {
792 .mailbox = { .id = 0, .data = 0,
793 .clr = ~0, .ok = 0, .fail = 0},
794 .method.data = 0,
795 .cond.ok = GR_IS_UCODE_OP_NOT_EQUAL,
796 .cond.fail = GR_IS_UCODE_OP_SKIP,
797 };
798 int err;
799
800 gk20a_dbg_fn("");
801
802 err = gr_gk20a_init_ctx_state(g);
803 if (err)
804 return err;
805
806 if (!g->gr.t18x.ctx_vars.preempt_image_size) {
807 op.method.addr =
808 gr_fecs_method_push_adr_discover_preemption_image_size_v();
809 op.mailbox.ret = &g->gr.t18x.ctx_vars.preempt_image_size;
810 err = gr_gk20a_submit_fecs_method_op(g, op, false);
811 if (err) {
812 gk20a_err(dev_from_gk20a(g),
813 "query preempt image size failed");
814 return err;
815 }
816 }
817
818 gk20a_dbg_info("preempt image size: %u",
819 g->gr.t18x.ctx_vars.preempt_image_size);
820
821 gk20a_dbg_fn("done");
822
823 return 0;
824}
825
826int gr_gp10b_alloc_buffer(struct vm_gk20a *vm, size_t size,
827 struct mem_desc *mem)
828{
829 int err;
830
831 gk20a_dbg_fn("");
832
833 err = gk20a_gmmu_alloc_sys(vm->mm->g, size, mem);
834 if (err)
835 return err;
836
837 mem->gpu_va = gk20a_gmmu_map(vm,
838 &mem->sgt,
839 size,
840 NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE,
841 gk20a_mem_flag_none,
842 false,
843 mem->aperture);
844
845 if (!mem->gpu_va) {
846 err = -ENOMEM;
847 goto fail_free;
848 }
849
850 return 0;
851
852fail_free:
853 gk20a_gmmu_free(vm->mm->g, mem);
854 return err;
855}
856
857static int gr_gp10b_set_ctxsw_preemption_mode(struct gk20a *g,
858 struct gr_ctx_desc *gr_ctx,
859 struct vm_gk20a *vm, u32 class,
860 u32 graphics_preempt_mode,
861 u32 compute_preempt_mode)
862{
863 int err = 0;
864
865 if (class == PASCAL_A && g->gr.t18x.ctx_vars.force_preemption_gfxp)
866 graphics_preempt_mode = NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP;
867
868 if (class == PASCAL_COMPUTE_A &&
869 g->gr.t18x.ctx_vars.force_preemption_cilp)
870 compute_preempt_mode = NVGPU_COMPUTE_PREEMPTION_MODE_CILP;
871
872 /* check for invalid combinations */
873 if ((graphics_preempt_mode == 0) && (compute_preempt_mode == 0))
874 return -EINVAL;
875
876 if ((graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) &&
877 (compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP))
878 return -EINVAL;
879
880 /* Do not allow lower preemption modes than current ones */
881 if (graphics_preempt_mode &&
882 (graphics_preempt_mode < gr_ctx->graphics_preempt_mode))
883 return -EINVAL;
884
885 if (compute_preempt_mode &&
886 (compute_preempt_mode < gr_ctx->compute_preempt_mode))
887 return -EINVAL;
888
889 /* set preemption modes */
890 switch (graphics_preempt_mode) {
891 case NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP:
892 {
893 u32 spill_size =
894 gr_gpc0_swdx_rm_spill_buffer_size_256b_default_v() *
895 gr_gpc0_swdx_rm_spill_buffer_size_256b_byte_granularity_v();
896 u32 pagepool_size = g->ops.gr.pagepool_default_size(g) *
897 gr_scc_pagepool_total_pages_byte_granularity_v();
898 u32 betacb_size = g->gr.attrib_cb_default_size +
899 (gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v() -
900 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v());
901 u32 attrib_cb_size = (betacb_size + g->gr.alpha_cb_size) *
902 gr_gpc0_ppc0_cbm_beta_cb_size_v_granularity_v() *
903 g->gr.max_tpc_count;
904 attrib_cb_size = ALIGN(attrib_cb_size, 128);
905
906 gk20a_dbg_info("gfxp context spill_size=%d", spill_size);
907 gk20a_dbg_info("gfxp context pagepool_size=%d", pagepool_size);
908 gk20a_dbg_info("gfxp context attrib_cb_size=%d",
909 attrib_cb_size);
910
911 err = gr_gp10b_alloc_buffer(vm,
912 g->gr.t18x.ctx_vars.preempt_image_size,
913 &gr_ctx->t18x.preempt_ctxsw_buffer);
914 if (err) {
915 gk20a_err(dev_from_gk20a(g),
916 "cannot allocate preempt buffer");
917 goto fail;
918 }
919
920 err = gr_gp10b_alloc_buffer(vm,
921 spill_size,
922 &gr_ctx->t18x.spill_ctxsw_buffer);
923 if (err) {
924 gk20a_err(dev_from_gk20a(g),
925 "cannot allocate spill buffer");
926 goto fail_free_preempt;
927 }
928
929 err = gr_gp10b_alloc_buffer(vm,
930 attrib_cb_size,
931 &gr_ctx->t18x.betacb_ctxsw_buffer);
932 if (err) {
933 gk20a_err(dev_from_gk20a(g),
934 "cannot allocate beta buffer");
935 goto fail_free_spill;
936 }
937
938 err = gr_gp10b_alloc_buffer(vm,
939 pagepool_size,
940 &gr_ctx->t18x.pagepool_ctxsw_buffer);
941 if (err) {
942 gk20a_err(dev_from_gk20a(g),
943 "cannot allocate page pool");
944 goto fail_free_betacb;
945 }
946
947 gr_ctx->graphics_preempt_mode = graphics_preempt_mode;
948 break;
949 }
950
951 case NVGPU_GRAPHICS_PREEMPTION_MODE_WFI:
952 gr_ctx->graphics_preempt_mode = graphics_preempt_mode;
953 break;
954
955 default:
956 break;
957 }
958
959 if (class == PASCAL_COMPUTE_A) {
960 switch (compute_preempt_mode) {
961 case NVGPU_COMPUTE_PREEMPTION_MODE_WFI:
962 case NVGPU_COMPUTE_PREEMPTION_MODE_CTA:
963 case NVGPU_COMPUTE_PREEMPTION_MODE_CILP:
964 gr_ctx->compute_preempt_mode = compute_preempt_mode;
965 break;
966 default:
967 break;
968 }
969 }
970
971 return 0;
972
973fail_free_betacb:
974 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.betacb_ctxsw_buffer);
975fail_free_spill:
976 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.spill_ctxsw_buffer);
977fail_free_preempt:
978 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.preempt_ctxsw_buffer);
979fail:
980 return err;
981}
982
983static int gr_gp10b_alloc_gr_ctx(struct gk20a *g,
984 struct gr_ctx_desc **gr_ctx, struct vm_gk20a *vm,
985 u32 class,
986 u32 flags)
987{
988 int err;
989 u32 graphics_preempt_mode = 0;
990 u32 compute_preempt_mode = 0;
991
992 gk20a_dbg_fn("");
993
994 err = gr_gk20a_alloc_gr_ctx(g, gr_ctx, vm, class, flags);
995 if (err)
996 return err;
997
998 (*gr_ctx)->t18x.ctx_id_valid = false;
999
1000 if (flags & NVGPU_ALLOC_OBJ_FLAGS_GFXP)
1001 graphics_preempt_mode = NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP;
1002 if (flags & NVGPU_ALLOC_OBJ_FLAGS_CILP)
1003 compute_preempt_mode = NVGPU_COMPUTE_PREEMPTION_MODE_CILP;
1004
1005 if (graphics_preempt_mode || compute_preempt_mode) {
1006 if (g->ops.gr.set_ctxsw_preemption_mode) {
1007 err = g->ops.gr.set_ctxsw_preemption_mode(g, *gr_ctx, vm,
1008 class, graphics_preempt_mode, compute_preempt_mode);
1009 if (err) {
1010 gk20a_err(dev_from_gk20a(g),
1011 "set_ctxsw_preemption_mode failed");
1012 goto fail_free_gk20a_ctx;
1013 }
1014 } else
1015 goto fail_free_gk20a_ctx;
1016 }
1017
1018 gk20a_dbg_fn("done");
1019
1020 return 0;
1021
1022fail_free_gk20a_ctx:
1023 gr_gk20a_free_gr_ctx(g, vm, *gr_ctx);
1024 *gr_ctx = NULL;
1025
1026 return err;
1027}
1028
1029static void dump_ctx_switch_stats(struct gk20a *g, struct vm_gk20a *vm,
1030 struct gr_ctx_desc *gr_ctx)
1031{
1032 struct mem_desc *mem = &gr_ctx->mem;
1033
1034 if (gk20a_mem_begin(g, mem)) {
1035 WARN_ON("Cannot map context");
1036 return;
1037 }
1038 gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_magic_value_o : %x (expect %x)\n",
1039 gk20a_mem_rd(g, mem,
1040 ctxsw_prog_main_image_magic_value_o()),
1041 ctxsw_prog_main_image_magic_value_v_value_v());
1042
1043 gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi : %x\n",
1044 gk20a_mem_rd(g, mem,
1045 ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_o()));
1046
1047 gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_context_timestamp_buffer_ptr : %x\n",
1048 gk20a_mem_rd(g, mem,
1049 ctxsw_prog_main_image_context_timestamp_buffer_ptr_o()));
1050
1051 gk20a_err(dev_from_gk20a(g), "ctxsw_prog_main_image_context_timestamp_buffer_control : %x\n",
1052 gk20a_mem_rd(g, mem,
1053 ctxsw_prog_main_image_context_timestamp_buffer_control_o()));
1054
1055 gk20a_err(dev_from_gk20a(g), "NUM_SAVE_OPERATIONS : %d\n",
1056 gk20a_mem_rd(g, mem,
1057 ctxsw_prog_main_image_num_save_ops_o()));
1058 gk20a_err(dev_from_gk20a(g), "WFI_SAVE_OPERATIONS : %d\n",
1059 gk20a_mem_rd(g, mem,
1060 ctxsw_prog_main_image_num_wfi_save_ops_o()));
1061 gk20a_err(dev_from_gk20a(g), "CTA_SAVE_OPERATIONS : %d\n",
1062 gk20a_mem_rd(g, mem,
1063 ctxsw_prog_main_image_num_cta_save_ops_o()));
1064 gk20a_err(dev_from_gk20a(g), "GFXP_SAVE_OPERATIONS : %d\n",
1065 gk20a_mem_rd(g, mem,
1066 ctxsw_prog_main_image_num_gfxp_save_ops_o()));
1067 gk20a_err(dev_from_gk20a(g), "CILP_SAVE_OPERATIONS : %d\n",
1068 gk20a_mem_rd(g, mem,
1069 ctxsw_prog_main_image_num_cilp_save_ops_o()));
1070 gk20a_err(dev_from_gk20a(g),
1071 "image gfx preemption option (GFXP is 1) %x\n",
1072 gk20a_mem_rd(g, mem,
1073 ctxsw_prog_main_image_graphics_preemption_options_o()));
1074 gk20a_mem_end(g, mem);
1075}
1076
1077static void gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm,
1078 struct gr_ctx_desc *gr_ctx)
1079{
1080 gk20a_dbg_fn("");
1081
1082 if (!gr_ctx)
1083 return;
1084
1085 if (g->gr.t18x.ctx_vars.dump_ctxsw_stats_on_channel_close)
1086 dump_ctx_switch_stats(g, vm, gr_ctx);
1087
1088 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.pagepool_ctxsw_buffer);
1089 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.betacb_ctxsw_buffer);
1090 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.spill_ctxsw_buffer);
1091 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.preempt_ctxsw_buffer);
1092 gr_gk20a_free_gr_ctx(g, vm, gr_ctx);
1093 gk20a_dbg_fn("done");
1094}
1095
1096
1097static void gr_gp10b_update_ctxsw_preemption_mode(struct gk20a *g,
1098 struct channel_ctx_gk20a *ch_ctx,
1099 struct mem_desc *mem)
1100{
1101 struct gr_ctx_desc *gr_ctx = ch_ctx->gr_ctx;
1102 u32 gfxp_preempt_option =
1103 ctxsw_prog_main_image_graphics_preemption_options_control_gfxp_f();
1104 u32 cilp_preempt_option =
1105 ctxsw_prog_main_image_compute_preemption_options_control_cilp_f();
1106 u32 cta_preempt_option =
1107 ctxsw_prog_main_image_compute_preemption_options_control_cta_f();
1108 int err;
1109
1110 gk20a_dbg_fn("");
1111
1112 if (gr_ctx->graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) {
1113 gk20a_dbg_info("GfxP: %x", gfxp_preempt_option);
1114 gk20a_mem_wr(g, mem,
1115 ctxsw_prog_main_image_graphics_preemption_options_o(),
1116 gfxp_preempt_option);
1117 }
1118
1119 if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP) {
1120 gk20a_dbg_info("CILP: %x", cilp_preempt_option);
1121 gk20a_mem_wr(g, mem,
1122 ctxsw_prog_main_image_compute_preemption_options_o(),
1123 cilp_preempt_option);
1124 }
1125
1126 if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CTA) {
1127 gk20a_dbg_info("CTA: %x", cta_preempt_option);
1128 gk20a_mem_wr(g, mem,
1129 ctxsw_prog_main_image_compute_preemption_options_o(),
1130 cta_preempt_option);
1131 }
1132
1133 if (gr_ctx->t18x.preempt_ctxsw_buffer.gpu_va) {
1134 u32 addr;
1135 u32 size;
1136 u32 cbes_reserve;
1137
1138 gk20a_mem_wr(g, mem,
1139 ctxsw_prog_main_image_full_preemption_ptr_o(),
1140 gr_ctx->t18x.preempt_ctxsw_buffer.gpu_va >> 8);
1141
1142 err = gr_gk20a_ctx_patch_write_begin(g, ch_ctx);
1143 if (err) {
1144 gk20a_err(dev_from_gk20a(g),
1145 "can't map patch context");
1146 goto out;
1147 }
1148
1149 addr = (u64_lo32(gr_ctx->t18x.betacb_ctxsw_buffer.gpu_va) >>
1150 gr_gpcs_setup_attrib_cb_base_addr_39_12_align_bits_v()) |
1151 (u64_hi32(gr_ctx->t18x.betacb_ctxsw_buffer.gpu_va) <<
1152 (32 - gr_gpcs_setup_attrib_cb_base_addr_39_12_align_bits_v()));
1153
1154 gk20a_dbg_info("attrib cb addr : 0x%016x", addr);
1155 g->ops.gr.commit_global_attrib_cb(g, ch_ctx, addr, true);
1156
1157 addr = (u64_lo32(gr_ctx->t18x.pagepool_ctxsw_buffer.gpu_va) >>
1158 gr_scc_pagepool_base_addr_39_8_align_bits_v()) |
1159 (u64_hi32(gr_ctx->t18x.pagepool_ctxsw_buffer.gpu_va) <<
1160 (32 - gr_scc_pagepool_base_addr_39_8_align_bits_v()));
1161 size = gr_ctx->t18x.pagepool_ctxsw_buffer.size;
1162
1163 if (size == g->ops.gr.pagepool_default_size(g))
1164 size = gr_scc_pagepool_total_pages_hwmax_v();
1165
1166 g->ops.gr.commit_global_pagepool(g, ch_ctx, addr, size, true);
1167
1168 addr = (u64_lo32(gr_ctx->t18x.spill_ctxsw_buffer.gpu_va) >>
1169 gr_gpc0_swdx_rm_spill_buffer_addr_39_8_align_bits_v()) |
1170 (u64_hi32(gr_ctx->t18x.spill_ctxsw_buffer.gpu_va) <<
1171 (32 - gr_gpc0_swdx_rm_spill_buffer_addr_39_8_align_bits_v()));
1172 size = gr_ctx->t18x.spill_ctxsw_buffer.size /
1173 gr_gpc0_swdx_rm_spill_buffer_size_256b_byte_granularity_v();
1174
1175 gr_gk20a_ctx_patch_write(g, ch_ctx,
1176 gr_gpc0_swdx_rm_spill_buffer_addr_r(),
1177 gr_gpc0_swdx_rm_spill_buffer_addr_39_8_f(addr),
1178 true);
1179 gr_gk20a_ctx_patch_write(g, ch_ctx,
1180 gr_gpc0_swdx_rm_spill_buffer_size_r(),
1181 gr_gpc0_swdx_rm_spill_buffer_size_256b_f(size),
1182 true);
1183
1184 cbes_reserve = gr_gpcs_swdx_beta_cb_ctrl_cbes_reserve_gfxp_v();
1185 gr_gk20a_ctx_patch_write(g, ch_ctx,
1186 gr_gpcs_swdx_beta_cb_ctrl_r(),
1187 gr_gpcs_swdx_beta_cb_ctrl_cbes_reserve_f(
1188 cbes_reserve),
1189 true);
1190 gr_gk20a_ctx_patch_write(g, ch_ctx,
1191 gr_gpcs_ppcs_cbm_beta_cb_ctrl_r(),
1192 gr_gpcs_ppcs_cbm_beta_cb_ctrl_cbes_reserve_f(
1193 cbes_reserve),
1194 true);
1195
1196 gr_gk20a_ctx_patch_write_end(g, ch_ctx);
1197 }
1198
1199out:
1200 gk20a_dbg_fn("done");
1201}
1202
1203static int gr_gp10b_dump_gr_status_regs(struct gk20a *g,
1204 struct gk20a_debug_output *o)
1205{
1206 struct gr_gk20a *gr = &g->gr;
1207 u32 gr_engine_id;
1208
1209 gr_engine_id = gk20a_fifo_get_gr_engine_id(g);
1210
1211 gk20a_debug_output(o, "NV_PGRAPH_STATUS: 0x%x\n",
1212 gk20a_readl(g, gr_status_r()));
1213 gk20a_debug_output(o, "NV_PGRAPH_STATUS1: 0x%x\n",
1214 gk20a_readl(g, gr_status_1_r()));
1215 gk20a_debug_output(o, "NV_PGRAPH_STATUS2: 0x%x\n",
1216 gk20a_readl(g, gr_status_2_r()));
1217 gk20a_debug_output(o, "NV_PGRAPH_ENGINE_STATUS: 0x%x\n",
1218 gk20a_readl(g, gr_engine_status_r()));
1219 gk20a_debug_output(o, "NV_PGRAPH_GRFIFO_STATUS : 0x%x\n",
1220 gk20a_readl(g, gr_gpfifo_status_r()));
1221 gk20a_debug_output(o, "NV_PGRAPH_GRFIFO_CONTROL : 0x%x\n",
1222 gk20a_readl(g, gr_gpfifo_ctl_r()));
1223 gk20a_debug_output(o, "NV_PGRAPH_PRI_FECS_HOST_INT_STATUS : 0x%x\n",
1224 gk20a_readl(g, gr_fecs_host_int_status_r()));
1225 gk20a_debug_output(o, "NV_PGRAPH_EXCEPTION : 0x%x\n",
1226 gk20a_readl(g, gr_exception_r()));
1227 gk20a_debug_output(o, "NV_PGRAPH_FECS_INTR : 0x%x\n",
1228 gk20a_readl(g, gr_fecs_intr_r()));
1229 gk20a_debug_output(o, "NV_PFIFO_ENGINE_STATUS(GR) : 0x%x\n",
1230 gk20a_readl(g, fifo_engine_status_r(gr_engine_id)));
1231 gk20a_debug_output(o, "NV_PGRAPH_ACTIVITY0: 0x%x\n",
1232 gk20a_readl(g, gr_activity_0_r()));
1233 gk20a_debug_output(o, "NV_PGRAPH_ACTIVITY1: 0x%x\n",
1234 gk20a_readl(g, gr_activity_1_r()));
1235 gk20a_debug_output(o, "NV_PGRAPH_ACTIVITY2: 0x%x\n",
1236 gk20a_readl(g, gr_activity_2_r()));
1237 gk20a_debug_output(o, "NV_PGRAPH_ACTIVITY4: 0x%x\n",
1238 gk20a_readl(g, gr_activity_4_r()));
1239 gk20a_debug_output(o, "NV_PGRAPH_PRI_SKED_ACTIVITY: 0x%x\n",
1240 gk20a_readl(g, gr_pri_sked_activity_r()));
1241 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_GPCCS_GPC_ACTIVITY0: 0x%x\n",
1242 gk20a_readl(g, gr_pri_gpc0_gpccs_gpc_activity0_r()));
1243 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_GPCCS_GPC_ACTIVITY1: 0x%x\n",
1244 gk20a_readl(g, gr_pri_gpc0_gpccs_gpc_activity1_r()));
1245 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_GPCCS_GPC_ACTIVITY2: 0x%x\n",
1246 gk20a_readl(g, gr_pri_gpc0_gpccs_gpc_activity2_r()));
1247 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_GPCCS_GPC_ACTIVITY3: 0x%x\n",
1248 gk20a_readl(g, gr_pri_gpc0_gpccs_gpc_activity3_r()));
1249 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_TPC0_TPCCS_TPC_ACTIVITY0: 0x%x\n",
1250 gk20a_readl(g, gr_pri_gpc0_tpc0_tpccs_tpc_activity_0_r()));
1251 if (gr->gpc_tpc_count[0] == 2)
1252 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_TPC1_TPCCS_TPC_ACTIVITY0: 0x%x\n",
1253 gk20a_readl(g, gr_pri_gpc0_tpc1_tpccs_tpc_activity_0_r()));
1254 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_TPCS_TPCCS_TPC_ACTIVITY0: 0x%x\n",
1255 gk20a_readl(g, gr_pri_gpc0_tpcs_tpccs_tpc_activity_0_r()));
1256 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPCS_GPCCS_GPC_ACTIVITY0: 0x%x\n",
1257 gk20a_readl(g, gr_pri_gpcs_gpccs_gpc_activity_0_r()));
1258 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPCS_GPCCS_GPC_ACTIVITY1: 0x%x\n",
1259 gk20a_readl(g, gr_pri_gpcs_gpccs_gpc_activity_1_r()));
1260 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPCS_GPCCS_GPC_ACTIVITY2: 0x%x\n",
1261 gk20a_readl(g, gr_pri_gpcs_gpccs_gpc_activity_2_r()));
1262 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPCS_GPCCS_GPC_ACTIVITY3: 0x%x\n",
1263 gk20a_readl(g, gr_pri_gpcs_gpccs_gpc_activity_3_r()));
1264 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPCS_TPC0_TPCCS_TPC_ACTIVITY0: 0x%x\n",
1265 gk20a_readl(g, gr_pri_gpcs_tpc0_tpccs_tpc_activity_0_r()));
1266 if (gr->gpc_tpc_count[0] == 2)
1267 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPCS_TPC1_TPCCS_TPC_ACTIVITY0: 0x%x\n",
1268 gk20a_readl(g, gr_pri_gpcs_tpc1_tpccs_tpc_activity_0_r()));
1269 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPCS_TPCS_TPCCS_TPC_ACTIVITY0: 0x%x\n",
1270 gk20a_readl(g, gr_pri_gpcs_tpcs_tpccs_tpc_activity_0_r()));
1271 gk20a_debug_output(o, "NV_PGRAPH_PRI_BE0_BECS_BE_ACTIVITY0: 0x%x\n",
1272 gk20a_readl(g, gr_pri_be0_becs_be_activity0_r()));
1273 gk20a_debug_output(o, "NV_PGRAPH_PRI_BE1_BECS_BE_ACTIVITY0: 0x%x\n",
1274 gk20a_readl(g, gr_pri_be1_becs_be_activity0_r()));
1275 gk20a_debug_output(o, "NV_PGRAPH_PRI_BES_BECS_BE_ACTIVITY0: 0x%x\n",
1276 gk20a_readl(g, gr_pri_bes_becs_be_activity0_r()));
1277 gk20a_debug_output(o, "NV_PGRAPH_PRI_DS_MPIPE_STATUS: 0x%x\n",
1278 gk20a_readl(g, gr_pri_ds_mpipe_status_r()));
1279 gk20a_debug_output(o, "NV_PGRAPH_PRI_FE_GO_IDLE_TIMEOUT : 0x%x\n",
1280 gk20a_readl(g, gr_fe_go_idle_timeout_r()));
1281 gk20a_debug_output(o, "NV_PGRAPH_PRI_FE_GO_IDLE_INFO : 0x%x\n",
1282 gk20a_readl(g, gr_pri_fe_go_idle_info_r()));
1283 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_TPC0_TEX_M_TEX_SUBUNITS_STATUS: 0x%x\n",
1284 gk20a_readl(g, gr_pri_gpc0_tpc0_tex_m_tex_subunits_status_r()));
1285 gk20a_debug_output(o, "NV_PGRAPH_PRI_CWD_FS: 0x%x\n",
1286 gk20a_readl(g, gr_cwd_fs_r()));
1287 gk20a_debug_output(o, "NV_PGRAPH_PRI_FE_TPC_FS: 0x%x\n",
1288 gk20a_readl(g, gr_fe_tpc_fs_r()));
1289 gk20a_debug_output(o, "NV_PGRAPH_PRI_CWD_GPC_TPC_ID(0): 0x%x\n",
1290 gk20a_readl(g, gr_cwd_gpc_tpc_id_r(0)));
1291 gk20a_debug_output(o, "NV_PGRAPH_PRI_CWD_SM_ID(0): 0x%x\n",
1292 gk20a_readl(g, gr_cwd_sm_id_r(0)));
1293 gk20a_debug_output(o, "NV_PGRAPH_PRI_FECS_CTXSW_STATUS_FE_0: 0x%x\n",
1294 gk20a_readl(g, gr_fecs_ctxsw_status_fe_0_r()));
1295 gk20a_debug_output(o, "NV_PGRAPH_PRI_FECS_CTXSW_STATUS_1: 0x%x\n",
1296 gk20a_readl(g, gr_fecs_ctxsw_status_1_r()));
1297 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_GPCCS_CTXSW_STATUS_GPC_0: 0x%x\n",
1298 gk20a_readl(g, gr_gpc0_gpccs_ctxsw_status_gpc_0_r()));
1299 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_GPCCS_CTXSW_STATUS_1: 0x%x\n",
1300 gk20a_readl(g, gr_gpc0_gpccs_ctxsw_status_1_r()));
1301 gk20a_debug_output(o, "NV_PGRAPH_PRI_FECS_CTXSW_IDLESTATE : 0x%x\n",
1302 gk20a_readl(g, gr_fecs_ctxsw_idlestate_r()));
1303 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_GPCCS_CTXSW_IDLESTATE : 0x%x\n",
1304 gk20a_readl(g, gr_gpc0_gpccs_ctxsw_idlestate_r()));
1305 gk20a_debug_output(o, "NV_PGRAPH_PRI_FECS_CURRENT_CTX : 0x%x\n",
1306 gk20a_readl(g, gr_fecs_current_ctx_r()));
1307 gk20a_debug_output(o, "NV_PGRAPH_PRI_FECS_NEW_CTX : 0x%x\n",
1308 gk20a_readl(g, gr_fecs_new_ctx_r()));
1309 gk20a_debug_output(o, "NV_PGRAPH_PRI_BE0_CROP_STATUS1 : 0x%x\n",
1310 gk20a_readl(g, gr_pri_be0_crop_status1_r()));
1311 gk20a_debug_output(o, "NV_PGRAPH_PRI_BES_CROP_STATUS1 : 0x%x\n",
1312 gk20a_readl(g, gr_pri_bes_crop_status1_r()));
1313 gk20a_debug_output(o, "NV_PGRAPH_PRI_BE0_ZROP_STATUS : 0x%x\n",
1314 gk20a_readl(g, gr_pri_be0_zrop_status_r()));
1315 gk20a_debug_output(o, "NV_PGRAPH_PRI_BE0_ZROP_STATUS2 : 0x%x\n",
1316 gk20a_readl(g, gr_pri_be0_zrop_status2_r()));
1317 gk20a_debug_output(o, "NV_PGRAPH_PRI_BES_ZROP_STATUS : 0x%x\n",
1318 gk20a_readl(g, gr_pri_bes_zrop_status_r()));
1319 gk20a_debug_output(o, "NV_PGRAPH_PRI_BES_ZROP_STATUS2 : 0x%x\n",
1320 gk20a_readl(g, gr_pri_bes_zrop_status2_r()));
1321 gk20a_debug_output(o, "NV_PGRAPH_PRI_BE0_BECS_BE_EXCEPTION: 0x%x\n",
1322 gk20a_readl(g, gr_pri_be0_becs_be_exception_r()));
1323 gk20a_debug_output(o, "NV_PGRAPH_PRI_BE0_BECS_BE_EXCEPTION_EN: 0x%x\n",
1324 gk20a_readl(g, gr_pri_be0_becs_be_exception_en_r()));
1325 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_GPCCS_GPC_EXCEPTION: 0x%x\n",
1326 gk20a_readl(g, gr_pri_gpc0_gpccs_gpc_exception_r()));
1327 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_GPCCS_GPC_EXCEPTION_EN: 0x%x\n",
1328 gk20a_readl(g, gr_pri_gpc0_gpccs_gpc_exception_en_r()));
1329 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_TPC0_TPCCS_TPC_EXCEPTION: 0x%x\n",
1330 gk20a_readl(g, gr_pri_gpc0_tpc0_tpccs_tpc_exception_r()));
1331 gk20a_debug_output(o, "NV_PGRAPH_PRI_GPC0_TPC0_TPCCS_TPC_EXCEPTION_EN: 0x%x\n",
1332 gk20a_readl(g, gr_pri_gpc0_tpc0_tpccs_tpc_exception_en_r()));
1333 return 0;
1334}
1335
1336static bool gr_activity_empty_or_preempted(u32 val)
1337{
1338 while(val) {
1339 u32 v = val & 7;
1340 if (v != gr_activity_4_gpc0_empty_v() &&
1341 v != gr_activity_4_gpc0_preempted_v())
1342 return false;
1343 val >>= 3;
1344 }
1345
1346 return true;
1347}
1348
1349static int gr_gp10b_wait_empty(struct gk20a *g, unsigned long end_jiffies,
1350 u32 expect_delay)
1351{
1352 u32 delay = expect_delay;
1353 bool gr_enabled;
1354 bool ctxsw_active;
1355 bool gr_busy;
1356 u32 gr_status;
1357 u32 activity0, activity1, activity2, activity4;
1358
1359 gk20a_dbg_fn("");
1360
1361 do {
1362 /* fmodel: host gets fifo_engine_status(gr) from gr
1363 only when gr_status is read */
1364 gr_status = gk20a_readl(g, gr_status_r());
1365
1366 gr_enabled = gk20a_readl(g, mc_enable_r()) &
1367 mc_enable_pgraph_enabled_f();
1368
1369 ctxsw_active = gr_status & 1<<7;
1370
1371 activity0 = gk20a_readl(g, gr_activity_0_r());
1372 activity1 = gk20a_readl(g, gr_activity_1_r());
1373 activity2 = gk20a_readl(g, gr_activity_2_r());
1374 activity4 = gk20a_readl(g, gr_activity_4_r());
1375
1376 gr_busy = !(gr_activity_empty_or_preempted(activity0) &&
1377 gr_activity_empty_or_preempted(activity1) &&
1378 activity2 == 0 &&
1379 gr_activity_empty_or_preempted(activity4));
1380
1381 if (!gr_enabled || (!gr_busy && !ctxsw_active)) {
1382 gk20a_dbg_fn("done");
1383 return 0;
1384 }
1385
1386 usleep_range(delay, delay * 2);
1387 delay = min_t(u32, delay << 1, GR_IDLE_CHECK_MAX);
1388
1389 } while (time_before(jiffies, end_jiffies)
1390 || !tegra_platform_is_silicon());
1391
1392 gk20a_err(dev_from_gk20a(g),
1393 "timeout, ctxsw busy : %d, gr busy : %d, %08x, %08x, %08x, %08x",
1394 ctxsw_active, gr_busy, activity0, activity1, activity2, activity4);
1395
1396 return -EAGAIN;
1397}
1398
1399static void gr_gp10b_commit_global_attrib_cb(struct gk20a *g,
1400 struct channel_ctx_gk20a *ch_ctx,
1401 u64 addr, bool patch)
1402{
1403 struct gr_ctx_desc *gr_ctx = ch_ctx->gr_ctx;
1404 int attrBufferSize;
1405
1406 if (gr_ctx->t18x.preempt_ctxsw_buffer.gpu_va)
1407 attrBufferSize = gr_ctx->t18x.betacb_ctxsw_buffer.size;
1408 else
1409 attrBufferSize = g->ops.gr.calc_global_ctx_buffer_size(g);
1410
1411 attrBufferSize /= gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_granularity_f();
1412
1413 gr_gm20b_commit_global_attrib_cb(g, ch_ctx, addr, patch);
1414
1415 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_r(),
1416 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_v_f(addr) |
1417 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_valid_true_f(), patch);
1418
1419 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_gpcs_tpcs_tex_rm_cb_0_r(),
1420 gr_gpcs_tpcs_tex_rm_cb_0_base_addr_43_12_f(addr), patch);
1421
1422 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_gpcs_tpcs_tex_rm_cb_1_r(),
1423 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_f(attrBufferSize) |
1424 gr_gpcs_tpcs_tex_rm_cb_1_valid_true_f(), patch);
1425}
1426
1427static void gr_gp10b_commit_global_bundle_cb(struct gk20a *g,
1428 struct channel_ctx_gk20a *ch_ctx,
1429 u64 addr, u64 size, bool patch)
1430{
1431 u32 data;
1432
1433 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_scc_bundle_cb_base_r(),
1434 gr_scc_bundle_cb_base_addr_39_8_f(addr), patch);
1435
1436 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_scc_bundle_cb_size_r(),
1437 gr_scc_bundle_cb_size_div_256b_f(size) |
1438 gr_scc_bundle_cb_size_valid_true_f(), patch);
1439
1440 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_gpcs_swdx_bundle_cb_base_r(),
1441 gr_gpcs_swdx_bundle_cb_base_addr_39_8_f(addr), patch);
1442
1443 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_gpcs_swdx_bundle_cb_size_r(),
1444 gr_gpcs_swdx_bundle_cb_size_div_256b_f(size) |
1445 gr_gpcs_swdx_bundle_cb_size_valid_true_f(), patch);
1446
1447 /* data for state_limit */
1448 data = (g->gr.bundle_cb_default_size *
1449 gr_scc_bundle_cb_size_div_256b_byte_granularity_v()) /
1450 gr_pd_ab_dist_cfg2_state_limit_scc_bundle_granularity_v();
1451
1452 data = min_t(u32, data, g->gr.min_gpm_fifo_depth);
1453
1454 gk20a_dbg_info("bundle cb token limit : %d, state limit : %d",
1455 g->gr.bundle_cb_token_limit, data);
1456
1457 gr_gk20a_ctx_patch_write(g, ch_ctx, gr_pd_ab_dist_cfg2_r(),
1458 gr_pd_ab_dist_cfg2_token_limit_f(g->gr.bundle_cb_token_limit) |
1459 gr_pd_ab_dist_cfg2_state_limit_f(data), patch);
1460}
1461
1462static int gr_gp10b_load_smid_config(struct gk20a *g)
1463{
1464 u32 *tpc_sm_id;
1465 u32 i, j;
1466 u32 tpc_index, gpc_index;
1467 u32 max_gpcs = nvgpu_get_litter_value(g, GPU_LIT_NUM_GPCS);
1468
1469 tpc_sm_id = kcalloc(gr_cwd_sm_id__size_1_v(), sizeof(u32), GFP_KERNEL);
1470 if (!tpc_sm_id)
1471 return -ENOMEM;
1472
1473 /* Each NV_PGRAPH_PRI_CWD_GPC_TPC_ID can store 4 TPCs.*/
1474 for (i = 0; i <= ((g->gr.tpc_count-1) / 4); i++) {
1475 u32 reg = 0;
1476 u32 bit_stride = gr_cwd_gpc_tpc_id_gpc0_s() +
1477 gr_cwd_gpc_tpc_id_tpc0_s();
1478
1479 for (j = 0; j < 4; j++) {
1480 u32 sm_id = (i * 4) + j;
1481 u32 bits;
1482
1483 if (sm_id >= g->gr.tpc_count)
1484 break;
1485
1486 gpc_index = g->gr.sm_to_cluster[sm_id].gpc_index;
1487 tpc_index = g->gr.sm_to_cluster[sm_id].tpc_index;
1488
1489 bits = gr_cwd_gpc_tpc_id_gpc0_f(gpc_index) |
1490 gr_cwd_gpc_tpc_id_tpc0_f(tpc_index);
1491 reg |= bits << (j * bit_stride);
1492
1493 tpc_sm_id[gpc_index + max_gpcs * ((tpc_index & 4) >> 2)]
1494 |= sm_id << (bit_stride * (tpc_index & 3));
1495 }
1496 gk20a_writel(g, gr_cwd_gpc_tpc_id_r(i), reg);
1497 }
1498
1499 for (i = 0; i < gr_cwd_sm_id__size_1_v(); i++)
1500 gk20a_writel(g, gr_cwd_sm_id_r(i), tpc_sm_id[i]);
1501
1502 kfree(tpc_sm_id);
1503
1504 return 0;
1505}
1506
1507int gr_gp10b_init_fs_state(struct gk20a *g)
1508{
1509 u32 data;
1510
1511 gk20a_dbg_fn("");
1512
1513 data = gk20a_readl(g, gr_gpcs_tpcs_sm_texio_control_r());
1514 data = set_field(data, gr_gpcs_tpcs_sm_texio_control_oor_addr_check_mode_m(),
1515 gr_gpcs_tpcs_sm_texio_control_oor_addr_check_mode_arm_63_48_match_f());
1516 gk20a_writel(g, gr_gpcs_tpcs_sm_texio_control_r(), data);
1517
1518 data = gk20a_readl(g, gr_gpcs_tpcs_sm_disp_ctrl_r());
1519 data = set_field(data, gr_gpcs_tpcs_sm_disp_ctrl_re_suppress_m(),
1520 gr_gpcs_tpcs_sm_disp_ctrl_re_suppress_disable_f());
1521 gk20a_writel(g, gr_gpcs_tpcs_sm_disp_ctrl_r(), data);
1522
1523 if (g->gr.t18x.fecs_feature_override_ecc_val != 0) {
1524 gk20a_writel(g,
1525 gr_fecs_feature_override_ecc_r(),
1526 g->gr.t18x.fecs_feature_override_ecc_val);
1527 }
1528
1529 return gr_gm20b_init_fs_state(g);
1530}
1531
1532static void gr_gp10b_init_cyclestats(struct gk20a *g)
1533{
1534#if defined(CONFIG_GK20A_CYCLE_STATS)
1535 g->gpu_characteristics.flags |=
1536 NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS;
1537 g->gpu_characteristics.flags |=
1538 NVGPU_GPU_FLAGS_SUPPORT_CYCLE_STATS_SNAPSHOT;
1539#else
1540 (void)g;
1541#endif
1542}
1543
1544static void gr_gp10b_set_gpc_tpc_mask(struct gk20a *g, u32 gpc_index)
1545{
1546 tegra_fuse_control_write(0x1, FUSE_FUSEBYPASS_0);
1547 tegra_fuse_control_write(0x0, FUSE_WRITE_ACCESS_SW_0);
1548
1549 if (g->gr.gpc_tpc_mask[gpc_index] == 0x1)
1550 tegra_fuse_control_write(0x2, FUSE_OPT_GPU_TPC0_DISABLE_0);
1551 else if (g->gr.gpc_tpc_mask[gpc_index] == 0x2)
1552 tegra_fuse_control_write(0x1, FUSE_OPT_GPU_TPC0_DISABLE_0);
1553 else
1554 tegra_fuse_control_write(0x0, FUSE_OPT_GPU_TPC0_DISABLE_0);
1555}
1556
1557static void gr_gp10b_get_access_map(struct gk20a *g,
1558 u32 **whitelist, int *num_entries)
1559{
1560 static u32 wl_addr_gp10b[] = {
1561 /* this list must be sorted (low to high) */
1562 0x404468, /* gr_pri_mme_max_instructions */
1563 0x418300, /* gr_pri_gpcs_rasterarb_line_class */
1564 0x418800, /* gr_pri_gpcs_setup_debug */
1565 0x418e00, /* gr_pri_gpcs_swdx_config */
1566 0x418e40, /* gr_pri_gpcs_swdx_tc_bundle_ctrl */
1567 0x418e44, /* gr_pri_gpcs_swdx_tc_bundle_ctrl */
1568 0x418e48, /* gr_pri_gpcs_swdx_tc_bundle_ctrl */
1569 0x418e4c, /* gr_pri_gpcs_swdx_tc_bundle_ctrl */
1570 0x418e50, /* gr_pri_gpcs_swdx_tc_bundle_ctrl */
1571 0x418e58, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1572 0x418e5c, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1573 0x418e60, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1574 0x418e64, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1575 0x418e68, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1576 0x418e6c, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1577 0x418e70, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1578 0x418e74, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1579 0x418e78, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1580 0x418e7c, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1581 0x418e80, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1582 0x418e84, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1583 0x418e88, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1584 0x418e8c, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1585 0x418e90, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1586 0x418e94, /* gr_pri_gpcs_swdx_tc_bundle_addr */
1587 0x419864, /* gr_pri_gpcs_tpcs_pe_l2_evict_policy */
1588 0x419a04, /* gr_pri_gpcs_tpcs_tex_lod_dbg */
1589 0x419a08, /* gr_pri_gpcs_tpcs_tex_samp_dbg */
1590 0x419e10, /* gr_pri_gpcs_tpcs_sm_dbgr_control0 */
1591 0x419f78, /* gr_pri_gpcs_tpcs_sm_disp_ctrl */
1592 };
1593
1594 *whitelist = wl_addr_gp10b;
1595 *num_entries = ARRAY_SIZE(wl_addr_gp10b);
1596}
1597
1598static int gr_gp10b_disable_channel_or_tsg(struct gk20a *g, struct channel_gk20a *fault_ch)
1599{
1600 int ret = 0;
1601
1602 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr, "");
1603
1604 ret = gk20a_disable_channel_tsg(g, fault_ch);
1605 if (ret) {
1606 gk20a_err(dev_from_gk20a(g),
1607 "CILP: failed to disable channel/TSG!\n");
1608 return ret;
1609 }
1610
1611 ret = g->ops.fifo.update_runlist(g, fault_ch->runlist_id, ~0, true, false);
1612 if (ret) {
1613 gk20a_err(dev_from_gk20a(g),
1614 "CILP: failed to restart runlist 0!");
1615 return ret;
1616 }
1617
1618 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr, "CILP: restarted runlist");
1619
1620 if (gk20a_is_channel_marked_as_tsg(fault_ch))
1621 gk20a_fifo_issue_preempt(g, fault_ch->tsgid, true);
1622 else
1623 gk20a_fifo_issue_preempt(g, fault_ch->hw_chid, false);
1624
1625 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr, "CILP: preempted the channel/tsg");
1626
1627 return ret;
1628}
1629
1630static int gr_gp10b_set_cilp_preempt_pending(struct gk20a *g, struct channel_gk20a *fault_ch)
1631{
1632 int ret;
1633 struct gr_ctx_desc *gr_ctx = fault_ch->ch_ctx.gr_ctx;
1634
1635 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr, "");
1636
1637 if (!gr_ctx)
1638 return -EINVAL;
1639
1640 if (gr_ctx->t18x.cilp_preempt_pending) {
1641 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr,
1642 "CILP is already pending for chid %d",
1643 fault_ch->hw_chid);
1644 return 0;
1645 }
1646
1647 /* get ctx_id from the ucode image */
1648 if (!gr_ctx->t18x.ctx_id_valid) {
1649 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr,
1650 "CILP: looking up ctx id");
1651 ret = gr_gk20a_get_ctx_id(g, fault_ch, &gr_ctx->t18x.ctx_id);
1652 if (ret) {
1653 gk20a_err(dev_from_gk20a(g), "CILP: error looking up ctx id!\n");
1654 return ret;
1655 }
1656 gr_ctx->t18x.ctx_id_valid = true;
1657 }
1658
1659 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr,
1660 "CILP: ctx id is 0x%x", gr_ctx->t18x.ctx_id);
1661
1662 /* send ucode method to set ctxsw interrupt */
1663 ret = gr_gk20a_submit_fecs_sideband_method_op(g,
1664 (struct fecs_method_op_gk20a) {
1665 .method.data = gr_ctx->t18x.ctx_id,
1666 .method.addr =
1667 gr_fecs_method_push_adr_configure_interrupt_completion_option_v(),
1668 .mailbox = {
1669 .id = 1 /* sideband */, .data = 0,
1670 .clr = ~0, .ret = NULL,
1671 .ok = gr_fecs_ctxsw_mailbox_value_pass_v(),
1672 .fail = 0},
1673 .cond.ok = GR_IS_UCODE_OP_EQUAL,
1674 .cond.fail = GR_IS_UCODE_OP_SKIP});
1675
1676 if (ret) {
1677 gk20a_err(dev_from_gk20a(g),
1678 "CILP: failed to enable ctxsw interrupt!");
1679 return ret;
1680 }
1681
1682 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr,
1683 "CILP: enabled ctxsw completion interrupt");
1684
1685 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr,
1686 "CILP: disabling channel %d",
1687 fault_ch->hw_chid);
1688
1689 ret = gr_gp10b_disable_channel_or_tsg(g, fault_ch);
1690 if (ret) {
1691 gk20a_err(dev_from_gk20a(g),
1692 "CILP: failed to disable channel!!");
1693 return ret;
1694 }
1695
1696 /* set cilp_preempt_pending = true and record the channel */
1697 gr_ctx->t18x.cilp_preempt_pending = true;
1698 g->gr.t18x.cilp_preempt_pending_chid = fault_ch->hw_chid;
1699
1700 if (gk20a_is_channel_marked_as_tsg(fault_ch)) {
1701 struct tsg_gk20a *tsg = &g->fifo.tsg[fault_ch->tsgid];
1702
1703 gk20a_tsg_event_id_post_event(tsg,
1704 NVGPU_IOCTL_CHANNEL_EVENT_ID_CILP_PREEMPTION_STARTED);
1705 } else {
1706 gk20a_channel_event_id_post_event(fault_ch,
1707 NVGPU_IOCTL_CHANNEL_EVENT_ID_CILP_PREEMPTION_STARTED);
1708 }
1709
1710 return 0;
1711}
1712
1713static int gr_gp10b_clear_cilp_preempt_pending(struct gk20a *g,
1714 struct channel_gk20a *fault_ch)
1715{
1716 struct gr_ctx_desc *gr_ctx = fault_ch->ch_ctx.gr_ctx;
1717
1718 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr, "");
1719
1720 if (!gr_ctx)
1721 return -EINVAL;
1722
1723 /* The ucode is self-clearing, so all we need to do here is
1724 to clear cilp_preempt_pending. */
1725 if (!gr_ctx->t18x.cilp_preempt_pending) {
1726 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr,
1727 "CILP is already cleared for chid %d\n",
1728 fault_ch->hw_chid);
1729 return 0;
1730 }
1731
1732 gr_ctx->t18x.cilp_preempt_pending = false;
1733 g->gr.t18x.cilp_preempt_pending_chid = -1;
1734
1735 return 0;
1736}
1737
1738/* @brief pre-process work on the SM exceptions to determine if we clear them or not.
1739 *
1740 * On Pascal, if we are in CILP preemtion mode, preempt the channel and handle errors with special processing
1741 */
1742static int gr_gp10b_pre_process_sm_exception(struct gk20a *g,
1743 u32 gpc, u32 tpc, u32 global_esr, u32 warp_esr,
1744 bool sm_debugger_attached, struct channel_gk20a *fault_ch,
1745 bool *early_exit, bool *ignore_debugger)
1746{
1747 int ret;
1748 bool cilp_enabled = (fault_ch->ch_ctx.gr_ctx->compute_preempt_mode ==
1749 NVGPU_COMPUTE_PREEMPTION_MODE_CILP) ;
1750 u32 global_mask = 0, dbgr_control0, global_esr_copy;
1751 u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE);
1752 u32 tpc_in_gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_TPC_IN_GPC_STRIDE);
1753 u32 offset = gpc_stride * gpc + tpc_in_gpc_stride * tpc;
1754
1755 *early_exit = false;
1756 *ignore_debugger = false;
1757
1758 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, "SM Exception received on gpc %d tpc %d = %u\n",
1759 gpc, tpc, global_esr);
1760
1761 if (cilp_enabled && sm_debugger_attached) {
1762 if (global_esr & gr_gpc0_tpc0_sm_hww_global_esr_bpt_int_pending_f())
1763 gk20a_writel(g, gr_gpc0_tpc0_sm_hww_global_esr_r() + offset,
1764 gr_gpc0_tpc0_sm_hww_global_esr_bpt_int_pending_f());
1765
1766 if (global_esr & gr_gpc0_tpc0_sm_hww_global_esr_single_step_complete_pending_f())
1767 gk20a_writel(g, gr_gpc0_tpc0_sm_hww_global_esr_r() + offset,
1768 gr_gpc0_tpc0_sm_hww_global_esr_single_step_complete_pending_f());
1769
1770 global_mask = gr_gpc0_tpc0_sm_hww_global_esr_sm_to_sm_fault_pending_f() |
1771 gr_gpcs_tpcs_sm_hww_global_esr_l1_error_pending_f() |
1772 gr_gpcs_tpcs_sm_hww_global_esr_multiple_warp_errors_pending_f() |
1773 gr_gpcs_tpcs_sm_hww_global_esr_physical_stack_overflow_error_pending_f() |
1774 gr_gpcs_tpcs_sm_hww_global_esr_timeout_error_pending_f() |
1775 gr_gpcs_tpcs_sm_hww_global_esr_bpt_pause_pending_f();
1776
1777 if (warp_esr != 0 || (global_esr & global_mask) != 0) {
1778 *ignore_debugger = true;
1779
1780 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg,
1781 "CILP: starting wait for LOCKED_DOWN on gpc %d tpc %d\n",
1782 gpc, tpc);
1783
1784 if (gk20a_dbg_gpu_broadcast_stop_trigger(fault_ch)) {
1785 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg,
1786 "CILP: Broadcasting STOP_TRIGGER from gpc %d tpc %d\n",
1787 gpc, tpc);
1788 gk20a_suspend_all_sms(g, global_mask, false);
1789
1790 gk20a_dbg_gpu_clear_broadcast_stop_trigger(fault_ch);
1791 } else {
1792 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg,
1793 "CILP: STOP_TRIGGER from gpc %d tpc %d\n",
1794 gpc, tpc);
1795 gk20a_suspend_single_sm(g, gpc, tpc, global_mask, true);
1796 }
1797
1798 /* reset the HWW errors after locking down */
1799 global_esr_copy = gk20a_readl(g, gr_gpc0_tpc0_sm_hww_global_esr_r() + offset);
1800 gk20a_gr_clear_sm_hww(g, gpc, tpc, global_esr_copy);
1801 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg,
1802 "CILP: HWWs cleared for gpc %d tpc %d\n",
1803 gpc, tpc);
1804
1805 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, "CILP: Setting CILP preempt pending\n");
1806 ret = gr_gp10b_set_cilp_preempt_pending(g, fault_ch);
1807 if (ret) {
1808 gk20a_err(dev_from_gk20a(g), "CILP: error while setting CILP preempt pending!\n");
1809 return ret;
1810 }
1811
1812 dbgr_control0 = gk20a_readl(g, gr_gpc0_tpc0_sm_dbgr_control0_r() + offset);
1813 if (dbgr_control0 & gr_gpcs_tpcs_sm_dbgr_control0_single_step_mode_enable_f()) {
1814 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg,
1815 "CILP: clearing SINGLE_STEP_MODE before resume for gpc %d tpc %d\n",
1816 gpc, tpc);
1817 dbgr_control0 = set_field(dbgr_control0,
1818 gr_gpcs_tpcs_sm_dbgr_control0_single_step_mode_m(),
1819 gr_gpcs_tpcs_sm_dbgr_control0_single_step_mode_disable_f());
1820 gk20a_writel(g, gr_gpc0_tpc0_sm_dbgr_control0_r() + offset, dbgr_control0);
1821 }
1822
1823 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg,
1824 "CILP: resume for gpc %d tpc %d\n",
1825 gpc, tpc);
1826 gk20a_resume_single_sm(g, gpc, tpc);
1827
1828 *ignore_debugger = true;
1829 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg, "CILP: All done on gpc %d, tpc %d\n", gpc, tpc);
1830 }
1831
1832 *early_exit = true;
1833 }
1834 return 0;
1835}
1836
1837static int gr_gp10b_get_cilp_preempt_pending_chid(struct gk20a *g, int *__chid)
1838{
1839 struct gr_ctx_desc *gr_ctx;
1840 struct channel_gk20a *ch;
1841 int chid;
1842 int ret = -EINVAL;
1843
1844 chid = g->gr.t18x.cilp_preempt_pending_chid;
1845
1846 ch = gk20a_channel_get(gk20a_fifo_channel_from_hw_chid(g, chid));
1847 if (!ch)
1848 return ret;
1849
1850 gr_ctx = ch->ch_ctx.gr_ctx;
1851
1852 if (gr_ctx->t18x.cilp_preempt_pending) {
1853 *__chid = chid;
1854 ret = 0;
1855 }
1856
1857 gk20a_channel_put(ch);
1858
1859 return ret;
1860}
1861
1862static int gr_gp10b_handle_fecs_error(struct gk20a *g,
1863 struct channel_gk20a *__ch,
1864 struct gr_gk20a_isr_data *isr_data)
1865{
1866 u32 gr_fecs_intr = gk20a_readl(g, gr_fecs_host_int_status_r());
1867 struct channel_gk20a *ch;
1868 int chid = -1;
1869 int ret = 0;
1870
1871 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr, "");
1872
1873 /*
1874 * INTR1 (bit 1 of the HOST_INT_STATUS_CTXSW_INTR)
1875 * indicates that a CILP ctxsw save has finished
1876 */
1877 if (gr_fecs_intr & gr_fecs_host_int_status_ctxsw_intr_f(2)) {
1878 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr,
1879 "CILP: ctxsw save completed!\n");
1880
1881 /* now clear the interrupt */
1882 gk20a_writel(g, gr_fecs_host_int_clear_r(),
1883 gr_fecs_host_int_clear_ctxsw_intr1_clear_f());
1884
1885 ret = gr_gp10b_get_cilp_preempt_pending_chid(g, &chid);
1886 if (ret)
1887 goto clean_up;
1888
1889 ch = gk20a_channel_get(
1890 gk20a_fifo_channel_from_hw_chid(g, chid));
1891 if (!ch)
1892 goto clean_up;
1893
1894
1895 /* set preempt_pending to false */
1896 ret = gr_gp10b_clear_cilp_preempt_pending(g, ch);
1897 if (ret) {
1898 gk20a_err(dev_from_gk20a(g), "CILP: error while unsetting CILP preempt pending!\n");
1899 gk20a_channel_put(ch);
1900 goto clean_up;
1901 }
1902
1903 /* Post events to UMD */
1904 gk20a_dbg_gpu_post_events(ch);
1905
1906 if (gk20a_is_channel_marked_as_tsg(ch)) {
1907 struct tsg_gk20a *tsg = &g->fifo.tsg[ch->tsgid];
1908
1909 gk20a_tsg_event_id_post_event(tsg,
1910 NVGPU_IOCTL_CHANNEL_EVENT_ID_CILP_PREEMPTION_COMPLETE);
1911 } else {
1912 gk20a_channel_event_id_post_event(ch,
1913 NVGPU_IOCTL_CHANNEL_EVENT_ID_CILP_PREEMPTION_COMPLETE);
1914 }
1915
1916 gk20a_channel_put(ch);
1917 }
1918
1919clean_up:
1920 /* handle any remaining interrupts */
1921 return gk20a_gr_handle_fecs_error(g, __ch, isr_data);
1922}
1923
1924static u32 gp10b_mask_hww_warp_esr(u32 hww_warp_esr)
1925{
1926 if (!(hww_warp_esr & gr_gpc0_tpc0_sm_hww_warp_esr_addr_valid_m()))
1927 hww_warp_esr = set_field(hww_warp_esr,
1928 gr_gpc0_tpc0_sm_hww_warp_esr_addr_error_type_m(),
1929 gr_gpc0_tpc0_sm_hww_warp_esr_addr_error_type_none_f());
1930
1931 return hww_warp_esr;
1932}
1933
1934static u32 get_ecc_override_val(struct gk20a *g)
1935{
1936 u32 val;
1937
1938 tegra_fuse_readl(FUSE_OPT_ECC_EN, &val);
1939 if (val)
1940 return gk20a_readl(g, gr_fecs_feature_override_ecc_r());
1941
1942 return 0;
1943}
1944
1945static bool gr_gp10b_suspend_context(struct channel_gk20a *ch,
1946 bool *cilp_preempt_pending)
1947{
1948 struct gk20a *g = ch->g;
1949 struct channel_ctx_gk20a *ch_ctx = &ch->ch_ctx;
1950 struct gr_ctx_desc *gr_ctx = ch_ctx->gr_ctx;
1951 bool ctx_resident = false;
1952 int err = 0;
1953
1954 *cilp_preempt_pending = false;
1955
1956 if (gk20a_is_channel_ctx_resident(ch)) {
1957 gk20a_suspend_all_sms(g, 0, false);
1958
1959 if (gr_ctx->compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP) {
1960 err = gr_gp10b_set_cilp_preempt_pending(g, ch);
1961 if (err)
1962 gk20a_err(dev_from_gk20a(g),
1963 "unable to set CILP preempt pending\n");
1964 else
1965 *cilp_preempt_pending = true;
1966
1967 gk20a_resume_all_sms(g);
1968 }
1969
1970 ctx_resident = true;
1971 } else {
1972 gk20a_disable_channel_tsg(g, ch);
1973 }
1974
1975 return ctx_resident;
1976}
1977
1978static int gr_gp10b_suspend_contexts(struct gk20a *g,
1979 struct dbg_session_gk20a *dbg_s,
1980 int *ctx_resident_ch_fd)
1981{
1982 u32 delay = GR_IDLE_CHECK_DEFAULT;
1983 bool cilp_preempt_pending = false;
1984 struct channel_gk20a *cilp_preempt_pending_ch = NULL;
1985 struct channel_gk20a *ch;
1986 struct dbg_session_channel_data *ch_data;
1987 int err = 0;
1988 int local_ctx_resident_ch_fd = -1;
1989 bool ctx_resident;
1990
1991 mutex_lock(&g->dbg_sessions_lock);
1992
1993 err = gr_gk20a_disable_ctxsw(g);
1994 if (err) {
1995 gk20a_err(dev_from_gk20a(g), "unable to stop gr ctxsw");
1996 mutex_unlock(&g->dbg_sessions_lock);
1997 goto clean_up;
1998 }
1999
2000 mutex_lock(&dbg_s->ch_list_lock);
2001
2002 list_for_each_entry(ch_data, &dbg_s->ch_list, ch_entry) {
2003 ch = g->fifo.channel + ch_data->chid;
2004
2005 ctx_resident = gr_gp10b_suspend_context(ch,
2006 &cilp_preempt_pending);
2007 if (ctx_resident)
2008 local_ctx_resident_ch_fd = ch_data->channel_fd;
2009 if (cilp_preempt_pending)
2010 cilp_preempt_pending_ch = ch;
2011 }
2012
2013 mutex_unlock(&dbg_s->ch_list_lock);
2014
2015 err = gr_gk20a_enable_ctxsw(g);
2016 if (err) {
2017 mutex_unlock(&g->dbg_sessions_lock);
2018 goto clean_up;
2019 }
2020
2021 mutex_unlock(&g->dbg_sessions_lock);
2022
2023 if (cilp_preempt_pending_ch) {
2024 struct channel_ctx_gk20a *ch_ctx =
2025 &cilp_preempt_pending_ch->ch_ctx;
2026 struct gr_ctx_desc *gr_ctx = ch_ctx->gr_ctx;
2027 unsigned long end_jiffies = jiffies +
2028 msecs_to_jiffies(gk20a_get_gr_idle_timeout(g));
2029
2030 gk20a_dbg(gpu_dbg_fn | gpu_dbg_gpu_dbg | gpu_dbg_intr,
2031 "CILP preempt pending, waiting %lu msecs for preemption",
2032 gk20a_get_gr_idle_timeout(g));
2033
2034 do {
2035 if (!gr_ctx->t18x.cilp_preempt_pending)
2036 break;
2037
2038 usleep_range(delay, delay * 2);
2039 delay = min_t(u32, delay << 1, GR_IDLE_CHECK_MAX);
2040 } while (time_before(jiffies, end_jiffies)
2041 || !tegra_platform_is_silicon());
2042
2043 /* If cilp is still pending at this point, timeout */
2044 if (gr_ctx->t18x.cilp_preempt_pending)
2045 err = -ETIMEDOUT;
2046 }
2047
2048 *ctx_resident_ch_fd = local_ctx_resident_ch_fd;
2049
2050clean_up:
2051 return err;
2052}
2053
2054static int gr_gp10b_set_preemption_mode(struct channel_gk20a *ch,
2055 u32 graphics_preempt_mode,
2056 u32 compute_preempt_mode)
2057{
2058 struct gr_ctx_desc *gr_ctx = ch->ch_ctx.gr_ctx;
2059 struct channel_ctx_gk20a *ch_ctx = &ch->ch_ctx;
2060 struct gk20a *g = ch->g;
2061 struct tsg_gk20a *tsg;
2062 struct vm_gk20a *vm;
2063 struct mem_desc *mem = &gr_ctx->mem;
2064 u32 class;
2065 int err = 0;
2066
2067 class = ch->obj_class;
2068 if (!class)
2069 return -EINVAL;
2070
2071 if (gk20a_is_channel_marked_as_tsg(ch)) {
2072 tsg = &g->fifo.tsg[ch->tsgid];
2073 vm = tsg->vm;
2074 } else {
2075 vm = ch->vm;
2076 }
2077
2078 /* skip setting anything if both modes are already set */
2079 if (graphics_preempt_mode &&
2080 (graphics_preempt_mode == gr_ctx->graphics_preempt_mode))
2081 graphics_preempt_mode = 0;
2082
2083 if (compute_preempt_mode &&
2084 (compute_preempt_mode == gr_ctx->compute_preempt_mode))
2085 compute_preempt_mode = 0;
2086
2087 if (graphics_preempt_mode == 0 && compute_preempt_mode == 0)
2088 return 0;
2089
2090 if (g->ops.gr.set_ctxsw_preemption_mode) {
2091 err = g->ops.gr.set_ctxsw_preemption_mode(g, gr_ctx, vm, class,
2092 graphics_preempt_mode, compute_preempt_mode);
2093 if (err) {
2094 gk20a_err(dev_from_gk20a(g),
2095 "set_ctxsw_preemption_mode failed");
2096 return err;
2097 }
2098 }
2099
2100 if (gk20a_mem_begin(g, mem))
2101 return -ENOMEM;
2102
2103 err = gk20a_disable_channel_tsg(g, ch);
2104 if (err)
2105 goto unmap_ctx;
2106
2107 err = gk20a_fifo_preempt(g, ch);
2108 if (err)
2109 goto enable_ch;
2110
2111 if (g->ops.gr.update_ctxsw_preemption_mode) {
2112 g->ops.gr.update_ctxsw_preemption_mode(ch->g, ch_ctx, mem);
2113
2114 err = gr_gk20a_ctx_patch_write_begin(g, ch_ctx);
2115 if (err) {
2116 gk20a_err(dev_from_gk20a(g),
2117 "can't map patch context");
2118 goto enable_ch;
2119 }
2120 g->ops.gr.commit_global_cb_manager(g, ch, true);
2121 gr_gk20a_ctx_patch_write_end(g, ch_ctx);
2122 }
2123
2124enable_ch:
2125 gk20a_enable_channel_tsg(g, ch);
2126unmap_ctx:
2127 gk20a_mem_end(g, mem);
2128
2129 return err;
2130}
2131
2132static int gr_gp10b_get_preemption_mode_flags(struct gk20a *g,
2133 struct nvgpu_preemption_modes_rec *preemption_modes_rec)
2134{
2135 preemption_modes_rec->graphics_preemption_mode_flags = (
2136 NVGPU_GRAPHICS_PREEMPTION_MODE_WFI |
2137 NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP);
2138 preemption_modes_rec->compute_preemption_mode_flags = (
2139 NVGPU_COMPUTE_PREEMPTION_MODE_WFI |
2140 NVGPU_COMPUTE_PREEMPTION_MODE_CTA |
2141 NVGPU_COMPUTE_PREEMPTION_MODE_CILP);
2142
2143 preemption_modes_rec->default_graphics_preempt_mode =
2144 NVGPU_GRAPHICS_PREEMPTION_MODE_WFI;
2145 preemption_modes_rec->default_compute_preempt_mode =
2146 NVGPU_COMPUTE_PREEMPTION_MODE_WFI;
2147
2148 return 0;
2149}
2150static int gp10b_gr_fuse_override(struct gk20a *g)
2151{
2152 struct device_node *np = g->dev->of_node;
2153 u32 *fuses;
2154 int count, i;
2155
2156 if (!np) /* may be pcie device */
2157 return 0;
2158
2159 count = of_property_count_elems_of_size(np, "fuse-overrides", 8);
2160 if (count <= 0)
2161 return count;
2162
2163 fuses = kmalloc(sizeof(u32) * count * 2, GFP_KERNEL);
2164 if (!fuses)
2165 return -ENOMEM;
2166 of_property_read_u32_array(np, "fuse-overrides", fuses, count * 2);
2167 for (i = 0; i < count; i++) {
2168 u32 fuse, value;
2169
2170 fuse = fuses[2 * i];
2171 value = fuses[2 * i + 1];
2172 switch (fuse) {
2173 case GM20B_FUSE_OPT_TPC_DISABLE:
2174 gm20b_gr_tpc_disable_override(g, value);
2175 break;
2176 case GP10B_FUSE_OPT_ECC_EN:
2177 g->gr.t18x.fecs_feature_override_ecc_val = value;
2178 break;
2179 default:
2180 gk20a_err(dev_from_gk20a(g),
2181 "ignore unknown fuse override %08x", fuse);
2182 break;
2183 }
2184 }
2185
2186 kfree(fuses);
2187
2188 return 0;
2189}
2190
2191static int gr_gp10b_init_preemption_state(struct gk20a *g)
2192{
2193 struct gk20a_platform *platform = gk20a_get_platform(g->dev);
2194 u32 debug_2;
2195 u64 sysclk_rate;
2196 u32 sysclk_cycles;
2197
2198 sysclk_rate = platform->clk_get_rate(g->dev);
2199 sysclk_cycles = (u32)((sysclk_rate * NVGPU_GFXP_WFI_TIMEOUT_US) / 1000000ULL);
2200 gk20a_writel(g, gr_fe_gfxp_wfi_timeout_r(),
2201 gr_fe_gfxp_wfi_timeout_count_f(sysclk_cycles));
2202
2203 debug_2 = gk20a_readl(g, gr_debug_2_r());
2204 debug_2 = set_field(debug_2,
2205 gr_debug_2_gfxp_wfi_always_injects_wfi_m(),
2206 gr_debug_2_gfxp_wfi_always_injects_wfi_enabled_f());
2207 gk20a_writel(g, gr_debug_2_r(), debug_2);
2208
2209 return 0;
2210}
2211
2212void gp10b_init_gr(struct gpu_ops *gops)
2213{
2214 gm20b_init_gr(gops);
2215 gops->gr.init_fs_state = gr_gp10b_init_fs_state;
2216 gops->gr.init_preemption_state = gr_gp10b_init_preemption_state;
2217 gops->gr.is_valid_class = gr_gp10b_is_valid_class;
2218 gops->gr.commit_global_cb_manager = gr_gp10b_commit_global_cb_manager;
2219 gops->gr.commit_global_pagepool = gr_gp10b_commit_global_pagepool;
2220 gops->gr.add_zbc_color = gr_gp10b_add_zbc_color;
2221 gops->gr.add_zbc_depth = gr_gp10b_add_zbc_depth;
2222 gops->gr.pagepool_default_size = gr_gp10b_pagepool_default_size;
2223 gops->gr.calc_global_ctx_buffer_size =
2224 gr_gp10b_calc_global_ctx_buffer_size;
2225 gops->gr.commit_global_attrib_cb = gr_gp10b_commit_global_attrib_cb;
2226 gops->gr.commit_global_bundle_cb = gr_gp10b_commit_global_bundle_cb;
2227 gops->gr.handle_sw_method = gr_gp10b_handle_sw_method;
2228 gops->gr.cb_size_default = gr_gp10b_cb_size_default;
2229 gops->gr.set_alpha_circular_buffer_size =
2230 gr_gp10b_set_alpha_circular_buffer_size;
2231 gops->gr.set_circular_buffer_size =
2232 gr_gp10b_set_circular_buffer_size;
2233 gops->gr.init_ctx_state = gr_gp10b_init_ctx_state;
2234 gops->gr.alloc_gr_ctx = gr_gp10b_alloc_gr_ctx;
2235 gops->gr.free_gr_ctx = gr_gp10b_free_gr_ctx;
2236 gops->gr.update_ctxsw_preemption_mode =
2237 gr_gp10b_update_ctxsw_preemption_mode;
2238 gops->gr.dump_gr_regs = gr_gp10b_dump_gr_status_regs;
2239 gops->gr.wait_empty = gr_gp10b_wait_empty;
2240 gops->gr.init_cyclestats = gr_gp10b_init_cyclestats;
2241 gops->gr.set_gpc_tpc_mask = gr_gp10b_set_gpc_tpc_mask;
2242 gops->gr.get_access_map = gr_gp10b_get_access_map;
2243 gops->gr.handle_sm_exception = gr_gp10b_handle_sm_exception;
2244 gops->gr.handle_tex_exception = gr_gp10b_handle_tex_exception;
2245 gops->gr.mask_hww_warp_esr = gp10b_mask_hww_warp_esr;
2246 gops->gr.pre_process_sm_exception =
2247 gr_gp10b_pre_process_sm_exception;
2248 gops->gr.handle_fecs_error = gr_gp10b_handle_fecs_error;
2249 gops->gr.create_gr_sysfs = gr_gp10b_create_sysfs;
2250 gops->gr.get_lrf_tex_ltc_dram_override = get_ecc_override_val;
2251 gops->gr.suspend_contexts = gr_gp10b_suspend_contexts;
2252 gops->gr.set_preemption_mode = gr_gp10b_set_preemption_mode;
2253 gops->gr.set_ctxsw_preemption_mode = gr_gp10b_set_ctxsw_preemption_mode;
2254 gops->gr.get_preemption_mode_flags = gr_gp10b_get_preemption_mode_flags;
2255 gops->gr.fuse_override = gp10b_gr_fuse_override;
2256 gops->gr.load_smid_config = gr_gp10b_load_smid_config;
2257}
diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.h b/drivers/gpu/nvgpu/gp10b/gr_gp10b.h
new file mode 100644
index 00000000..5338789f
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.h
@@ -0,0 +1,103 @@
1/*
2 * GP10B GPU GR
3 *
4 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _NVGPU_GR_GP10B_H_
17#define _NVGPU_GR_GP10B_H_
18
19#include <linux/version.h>
20
21struct gpu_ops;
22
23enum {
24 PASCAL_CHANNEL_GPFIFO_A = 0xC06F,
25 PASCAL_A = 0xC097,
26 PASCAL_COMPUTE_A = 0xC0C0,
27 PASCAL_DMA_COPY_A = 0xC0B5,
28 PASCAL_DMA_COPY_B = 0xC1B5,
29};
30
31#define NVC097_SET_GO_IDLE_TIMEOUT 0x022c
32#define NVC097_SET_ALPHA_CIRCULAR_BUFFER_SIZE 0x02dc
33#define NVC097_SET_COALESCE_BUFFER_SIZE 0x1028
34#define NVC097_SET_CIRCULAR_BUFFER_SIZE 0x1280
35#define NVC097_SET_SHADER_EXCEPTIONS 0x1528
36#define NVC0C0_SET_SHADER_EXCEPTIONS 0x1528
37
38void gp10b_init_gr(struct gpu_ops *ops);
39int gr_gp10b_init_fs_state(struct gk20a *g);
40int gr_gp10b_alloc_buffer(struct vm_gk20a *vm, size_t size,
41 struct mem_desc *mem);
42void gr_gp10b_create_sysfs(struct device *dev);
43
44struct ecc_stat {
45 char **names;
46 u32 *counters;
47 struct hlist_node hash_node;
48};
49
50struct gr_t18x {
51 struct {
52 u32 preempt_image_size;
53#if LINUX_VERSION_CODE < KERNEL_VERSION(4,4,0)
54 u32 force_preemption_gfxp;
55 u32 force_preemption_cilp;
56 u32 dump_ctxsw_stats_on_channel_close;
57#else
58 bool force_preemption_gfxp;
59 bool force_preemption_cilp;
60 bool dump_ctxsw_stats_on_channel_close;
61#endif
62 struct dentry *debugfs_force_preemption_cilp;
63 struct dentry *debugfs_force_preemption_gfxp;
64 struct dentry *debugfs_dump_ctxsw_stats;
65 } ctx_vars;
66
67 struct {
68 struct ecc_stat sm_lrf_single_err_count;
69 struct ecc_stat sm_lrf_double_err_count;
70
71 struct ecc_stat sm_shm_sec_count;
72 struct ecc_stat sm_shm_sed_count;
73 struct ecc_stat sm_shm_ded_count;
74
75 struct ecc_stat tex_total_sec_pipe0_count;
76 struct ecc_stat tex_total_ded_pipe0_count;
77 struct ecc_stat tex_unique_sec_pipe0_count;
78 struct ecc_stat tex_unique_ded_pipe0_count;
79 struct ecc_stat tex_total_sec_pipe1_count;
80 struct ecc_stat tex_total_ded_pipe1_count;
81 struct ecc_stat tex_unique_sec_pipe1_count;
82 struct ecc_stat tex_unique_ded_pipe1_count;
83
84 struct ecc_stat l2_sec_count;
85 struct ecc_stat l2_ded_count;
86 } ecc_stats;
87
88 u32 fecs_feature_override_ecc_val;
89
90 int cilp_preempt_pending_chid;
91};
92
93struct gr_ctx_desc_t18x {
94 struct mem_desc preempt_ctxsw_buffer;
95 struct mem_desc spill_ctxsw_buffer;
96 struct mem_desc betacb_ctxsw_buffer;
97 struct mem_desc pagepool_ctxsw_buffer;
98 u32 ctx_id;
99 bool ctx_id_valid;
100 bool cilp_preempt_pending;
101};
102
103#endif
diff --git a/drivers/gpu/nvgpu/gp10b/gr_ops_gp10b.h b/drivers/gpu/nvgpu/gp10b/gr_ops_gp10b.h
new file mode 100644
index 00000000..c3277017
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/gr_ops_gp10b.h
@@ -0,0 +1,28 @@
1/*
2 * GP10B GPU graphics ops
3 *
4 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _GR_OPS_GP10B_H_
17#define _GR_OPS_GP10B_H_
18
19#include "gr_ops.h"
20
21#define __gr_gp10b_op(X) gr_gp10b_ ## X
22#define __set_gr_gp10b_op(X) . X = gr_gp10b_ ## X
23
24bool __gr_gp10b_op(is_valid_class)(struct gk20a *, u32);
25int __gr_gp10b_op(alloc_obj_ctx)(struct channel_gk20a *, struct nvgpu_alloc_obj_ctx_args *);
26
27
28#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hal_gp10b.c b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
new file mode 100644
index 00000000..a656f10d
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hal_gp10b.c
@@ -0,0 +1,269 @@
1/*
2 * GP10B Tegra HAL interface
3 *
4 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/types.h>
17#include <linux/printk.h>
18#include <linux/version.h>
19
20#include <linux/types.h>
21
22#include "gk20a/gk20a.h"
23
24#include "gp10b/gr_gp10b.h"
25#include "gp10b/fecs_trace_gp10b.h"
26#include "gp10b/mc_gp10b.h"
27#include "gp10b/ltc_gp10b.h"
28#include "gp10b/mm_gp10b.h"
29#include "gp10b/ce_gp10b.h"
30#include "gp10b/fb_gp10b.h"
31#include "gp10b/pmu_gp10b.h"
32#include "gp10b/gr_ctx_gp10b.h"
33#include "gp10b/fifo_gp10b.h"
34#include "gp10b/gp10b_gating_reglist.h"
35#include "gp10b/regops_gp10b.h"
36#include "gp10b/cde_gp10b.h"
37#include "gp10b/therm_gp10b.h"
38
39#include "gm20b/gr_gm20b.h"
40#include "gm20b/fifo_gm20b.h"
41#include "gm20b/pmu_gm20b.h"
42#include "gm20b/clk_gm20b.h"
43#include <linux/tegra-fuse.h>
44
45#include "gp10b.h"
46#include "hw_proj_gp10b.h"
47#include "gk20a/dbg_gpu_gk20a.h"
48#include "gk20a/css_gr_gk20a.h"
49
50#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
51#define FUSE_OPT_PRIV_SEC_EN_0 0x264
52#endif
53#define PRIV_SECURITY_ENABLED 0x01
54
55static struct gpu_ops gp10b_ops = {
56 .clock_gating = {
57 .slcg_bus_load_gating_prod =
58 gp10b_slcg_bus_load_gating_prod,
59 .slcg_ce2_load_gating_prod =
60 gp10b_slcg_ce2_load_gating_prod,
61 .slcg_chiplet_load_gating_prod =
62 gp10b_slcg_chiplet_load_gating_prod,
63 .slcg_ctxsw_firmware_load_gating_prod =
64 gp10b_slcg_ctxsw_firmware_load_gating_prod,
65 .slcg_fb_load_gating_prod =
66 gp10b_slcg_fb_load_gating_prod,
67 .slcg_fifo_load_gating_prod =
68 gp10b_slcg_fifo_load_gating_prod,
69 .slcg_gr_load_gating_prod =
70 gr_gp10b_slcg_gr_load_gating_prod,
71 .slcg_ltc_load_gating_prod =
72 ltc_gp10b_slcg_ltc_load_gating_prod,
73 .slcg_perf_load_gating_prod =
74 gp10b_slcg_perf_load_gating_prod,
75 .slcg_priring_load_gating_prod =
76 gp10b_slcg_priring_load_gating_prod,
77 .slcg_pmu_load_gating_prod =
78 gp10b_slcg_pmu_load_gating_prod,
79 .slcg_therm_load_gating_prod =
80 gp10b_slcg_therm_load_gating_prod,
81 .slcg_xbar_load_gating_prod =
82 gp10b_slcg_xbar_load_gating_prod,
83 .blcg_bus_load_gating_prod =
84 gp10b_blcg_bus_load_gating_prod,
85 .blcg_ce_load_gating_prod =
86 gp10b_blcg_ce_load_gating_prod,
87 .blcg_ctxsw_firmware_load_gating_prod =
88 gp10b_blcg_ctxsw_firmware_load_gating_prod,
89 .blcg_fb_load_gating_prod =
90 gp10b_blcg_fb_load_gating_prod,
91 .blcg_fifo_load_gating_prod =
92 gp10b_blcg_fifo_load_gating_prod,
93 .blcg_gr_load_gating_prod =
94 gp10b_blcg_gr_load_gating_prod,
95 .blcg_ltc_load_gating_prod =
96 gp10b_blcg_ltc_load_gating_prod,
97 .blcg_pwr_csb_load_gating_prod =
98 gp10b_blcg_pwr_csb_load_gating_prod,
99 .blcg_pmu_load_gating_prod =
100 gp10b_blcg_pmu_load_gating_prod,
101 .blcg_xbar_load_gating_prod =
102 gp10b_blcg_xbar_load_gating_prod,
103 .pg_gr_load_gating_prod =
104 gr_gp10b_pg_gr_load_gating_prod,
105 }
106};
107
108static int gp10b_get_litter_value(struct gk20a *g, int value)
109{
110 int ret = EINVAL;
111 switch (value) {
112 case GPU_LIT_NUM_GPCS:
113 ret = proj_scal_litter_num_gpcs_v();
114 break;
115 case GPU_LIT_NUM_PES_PER_GPC:
116 ret = proj_scal_litter_num_pes_per_gpc_v();
117 break;
118 case GPU_LIT_NUM_ZCULL_BANKS:
119 ret = proj_scal_litter_num_zcull_banks_v();
120 break;
121 case GPU_LIT_NUM_TPC_PER_GPC:
122 ret = proj_scal_litter_num_tpc_per_gpc_v();
123 break;
124 case GPU_LIT_NUM_FBPS:
125 ret = proj_scal_litter_num_fbps_v();
126 break;
127 case GPU_LIT_GPC_BASE:
128 ret = proj_gpc_base_v();
129 break;
130 case GPU_LIT_GPC_STRIDE:
131 ret = proj_gpc_stride_v();
132 break;
133 case GPU_LIT_GPC_SHARED_BASE:
134 ret = proj_gpc_shared_base_v();
135 break;
136 case GPU_LIT_TPC_IN_GPC_BASE:
137 ret = proj_tpc_in_gpc_base_v();
138 break;
139 case GPU_LIT_TPC_IN_GPC_STRIDE:
140 ret = proj_tpc_in_gpc_stride_v();
141 break;
142 case GPU_LIT_TPC_IN_GPC_SHARED_BASE:
143 ret = proj_tpc_in_gpc_shared_base_v();
144 break;
145 case GPU_LIT_PPC_IN_GPC_BASE:
146 ret = proj_ppc_in_gpc_base_v();
147 break;
148 case GPU_LIT_PPC_IN_GPC_STRIDE:
149 ret = proj_ppc_in_gpc_stride_v();
150 break;
151 case GPU_LIT_PPC_IN_GPC_SHARED_BASE:
152 ret = proj_ppc_in_gpc_shared_base_v();
153 break;
154 case GPU_LIT_ROP_BASE:
155 ret = proj_rop_base_v();
156 break;
157 case GPU_LIT_ROP_STRIDE:
158 ret = proj_rop_stride_v();
159 break;
160 case GPU_LIT_ROP_SHARED_BASE:
161 ret = proj_rop_shared_base_v();
162 break;
163 case GPU_LIT_HOST_NUM_ENGINES:
164 ret = proj_host_num_engines_v();
165 break;
166 case GPU_LIT_HOST_NUM_PBDMA:
167 ret = proj_host_num_pbdma_v();
168 break;
169 case GPU_LIT_LTC_STRIDE:
170 ret = proj_ltc_stride_v();
171 break;
172 case GPU_LIT_LTS_STRIDE:
173 ret = proj_lts_stride_v();
174 break;
175 /* GP10B does not have a FBPA unit, despite what's listed in the
176 * hw headers or read back through NV_PTOP_SCAL_NUM_FBPAS,
177 * so hardcode all values to 0.
178 */
179 case GPU_LIT_NUM_FBPAS:
180 case GPU_LIT_FBPA_STRIDE:
181 case GPU_LIT_FBPA_BASE:
182 case GPU_LIT_FBPA_SHARED_BASE:
183 ret = 0;
184 break;
185 default:
186 gk20a_err(dev_from_gk20a(g), "Missing definition %d", value);
187 BUG();
188 break;
189 }
190
191 return ret;
192}
193
194int gp10b_init_hal(struct gk20a *g)
195{
196 struct gpu_ops *gops = &g->ops;
197 struct nvgpu_gpu_characteristics *c = &g->gpu_characteristics;
198 struct gk20a_platform *platform = dev_get_drvdata(g->dev);
199 u32 val;
200
201 *gops = gp10b_ops;
202 gops->pmupstate = false;
203#ifdef CONFIG_TEGRA_ACR
204 if (platform->is_fmodel) {
205 gops->privsecurity = 0;
206 gops->securegpccs = 0;
207 } else {
208 tegra_fuse_readl(FUSE_OPT_PRIV_SEC_EN_0, &val);
209 if (val & PRIV_SECURITY_ENABLED) {
210 gops->privsecurity = 1;
211 gops->securegpccs =1;
212 } else {
213 gk20a_dbg_info("priv security is disabled in HW");
214 gops->privsecurity = 0;
215 gops->securegpccs = 0;
216 }
217 }
218#else
219 if (platform->is_fmodel) {
220 gk20a_dbg_info("running simulator with PRIV security disabled");
221 gops->privsecurity = 0;
222 gops->securegpccs = 0;
223 } else {
224 tegra_fuse_readl(FUSE_OPT_PRIV_SEC_EN_0, &val);
225 if (val & PRIV_SECURITY_ENABLED) {
226 gk20a_dbg_info("priv security is not supported but enabled");
227 gops->privsecurity = 1;
228 gops->securegpccs =1;
229 return -EPERM;
230 } else {
231 gops->privsecurity = 0;
232 gops->securegpccs = 0;
233 }
234 }
235#endif
236
237 gp10b_init_mc(gops);
238 gp10b_init_gr(gops);
239 gp10b_init_fecs_trace_ops(gops);
240 gp10b_init_ltc(gops);
241 gp10b_init_fb(gops);
242 gp10b_init_fifo(gops);
243 gp10b_init_ce(gops);
244 gp10b_init_gr_ctx(gops);
245 gp10b_init_mm(gops);
246 gp10b_init_pmu_ops(gops);
247 gk20a_init_debug_ops(gops);
248 gk20a_init_dbg_session_ops(gops);
249 gp10b_init_regops(gops);
250 gp10b_init_cde_ops(gops);
251 gp10b_init_therm_ops(gops);
252 gk20a_init_tsg_ops(gops);
253#if defined(CONFIG_GK20A_CYCLE_STATS)
254 gk20a_init_css_ops(gops);
255#endif
256 gops->name = "gp10b";
257 gops->chip_init_gpu_characteristics = gp10b_init_gpu_characteristics;
258 gops->get_litter_value = gp10b_get_litter_value;
259 gops->read_ptimer = gk20a_read_ptimer;
260
261 c->twod_class = FERMI_TWOD_A;
262 c->threed_class = PASCAL_A;
263 c->compute_class = PASCAL_COMPUTE_A;
264 c->gpfifo_class = PASCAL_CHANNEL_GPFIFO_A;
265 c->inline_to_memory_class = KEPLER_INLINE_TO_MEMORY_B;
266 c->dma_copy_class = PASCAL_DMA_COPY_A;
267
268 return 0;
269}
diff --git a/drivers/gpu/nvgpu/gp10b/hal_gp10b.h b/drivers/gpu/nvgpu/gp10b/hal_gp10b.h
new file mode 100644
index 00000000..0b464d07
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hal_gp10b.h
@@ -0,0 +1,21 @@
1/*
2 * GP10B Tegra HAL interface
3 *
4 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef _NVGPU_HAL_GP10B_H
17#define _NVGPU_HAL_GP10B_H
18struct gk20a;
19
20int gp10b_init_hal(struct gk20a *gops);
21#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_bus_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_bus_gp10b.h
new file mode 100644
index 00000000..02c06610
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_bus_gp10b.h
@@ -0,0 +1,217 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_bus_gp10b_h_
51#define _hw_bus_gp10b_h_
52
53static inline u32 bus_bar0_window_r(void)
54{
55 return 0x00001700;
56}
57static inline u32 bus_bar0_window_base_f(u32 v)
58{
59 return (v & 0xffffff) << 0;
60}
61static inline u32 bus_bar0_window_target_vid_mem_f(void)
62{
63 return 0x0;
64}
65static inline u32 bus_bar0_window_target_sys_mem_coherent_f(void)
66{
67 return 0x2000000;
68}
69static inline u32 bus_bar0_window_target_sys_mem_noncoherent_f(void)
70{
71 return 0x3000000;
72}
73static inline u32 bus_bar0_window_target_bar0_window_base_shift_v(void)
74{
75 return 0x00000010;
76}
77static inline u32 bus_bar1_block_r(void)
78{
79 return 0x00001704;
80}
81static inline u32 bus_bar1_block_ptr_f(u32 v)
82{
83 return (v & 0xfffffff) << 0;
84}
85static inline u32 bus_bar1_block_target_vid_mem_f(void)
86{
87 return 0x0;
88}
89static inline u32 bus_bar1_block_target_sys_mem_coh_f(void)
90{
91 return 0x20000000;
92}
93static inline u32 bus_bar1_block_target_sys_mem_ncoh_f(void)
94{
95 return 0x30000000;
96}
97static inline u32 bus_bar1_block_mode_virtual_f(void)
98{
99 return 0x80000000;
100}
101static inline u32 bus_bar2_block_r(void)
102{
103 return 0x00001714;
104}
105static inline u32 bus_bar2_block_ptr_f(u32 v)
106{
107 return (v & 0xfffffff) << 0;
108}
109static inline u32 bus_bar2_block_target_vid_mem_f(void)
110{
111 return 0x0;
112}
113static inline u32 bus_bar2_block_target_sys_mem_coh_f(void)
114{
115 return 0x20000000;
116}
117static inline u32 bus_bar2_block_target_sys_mem_ncoh_f(void)
118{
119 return 0x30000000;
120}
121static inline u32 bus_bar2_block_mode_virtual_f(void)
122{
123 return 0x80000000;
124}
125static inline u32 bus_bar1_block_ptr_shift_v(void)
126{
127 return 0x0000000c;
128}
129static inline u32 bus_bar2_block_ptr_shift_v(void)
130{
131 return 0x0000000c;
132}
133static inline u32 bus_bind_status_r(void)
134{
135 return 0x00001710;
136}
137static inline u32 bus_bind_status_bar1_pending_v(u32 r)
138{
139 return (r >> 0) & 0x1;
140}
141static inline u32 bus_bind_status_bar1_pending_empty_f(void)
142{
143 return 0x0;
144}
145static inline u32 bus_bind_status_bar1_pending_busy_f(void)
146{
147 return 0x1;
148}
149static inline u32 bus_bind_status_bar1_outstanding_v(u32 r)
150{
151 return (r >> 1) & 0x1;
152}
153static inline u32 bus_bind_status_bar1_outstanding_false_f(void)
154{
155 return 0x0;
156}
157static inline u32 bus_bind_status_bar1_outstanding_true_f(void)
158{
159 return 0x2;
160}
161static inline u32 bus_bind_status_bar2_pending_v(u32 r)
162{
163 return (r >> 2) & 0x1;
164}
165static inline u32 bus_bind_status_bar2_pending_empty_f(void)
166{
167 return 0x0;
168}
169static inline u32 bus_bind_status_bar2_pending_busy_f(void)
170{
171 return 0x4;
172}
173static inline u32 bus_bind_status_bar2_outstanding_v(u32 r)
174{
175 return (r >> 3) & 0x1;
176}
177static inline u32 bus_bind_status_bar2_outstanding_false_f(void)
178{
179 return 0x0;
180}
181static inline u32 bus_bind_status_bar2_outstanding_true_f(void)
182{
183 return 0x8;
184}
185static inline u32 bus_intr_0_r(void)
186{
187 return 0x00001100;
188}
189static inline u32 bus_intr_0_pri_squash_m(void)
190{
191 return 0x1 << 1;
192}
193static inline u32 bus_intr_0_pri_fecserr_m(void)
194{
195 return 0x1 << 2;
196}
197static inline u32 bus_intr_0_pri_timeout_m(void)
198{
199 return 0x1 << 3;
200}
201static inline u32 bus_intr_en_0_r(void)
202{
203 return 0x00001140;
204}
205static inline u32 bus_intr_en_0_pri_squash_m(void)
206{
207 return 0x1 << 1;
208}
209static inline u32 bus_intr_en_0_pri_fecserr_m(void)
210{
211 return 0x1 << 2;
212}
213static inline u32 bus_intr_en_0_pri_timeout_m(void)
214{
215 return 0x1 << 3;
216}
217#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_ccsr_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_ccsr_gp10b.h
new file mode 100644
index 00000000..99398961
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_ccsr_gp10b.h
@@ -0,0 +1,117 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ccsr_gp10b_h_
51#define _hw_ccsr_gp10b_h_
52
53static inline u32 ccsr_channel_inst_r(u32 i)
54{
55 return 0x00800000 + i*8;
56}
57static inline u32 ccsr_channel_inst__size_1_v(void)
58{
59 return 0x00000200;
60}
61static inline u32 ccsr_channel_inst_ptr_f(u32 v)
62{
63 return (v & 0xfffffff) << 0;
64}
65static inline u32 ccsr_channel_inst_target_vid_mem_f(void)
66{
67 return 0x0;
68}
69static inline u32 ccsr_channel_inst_target_sys_mem_coh_f(void)
70{
71 return 0x20000000;
72}
73static inline u32 ccsr_channel_inst_target_sys_mem_ncoh_f(void)
74{
75 return 0x30000000;
76}
77static inline u32 ccsr_channel_inst_bind_false_f(void)
78{
79 return 0x0;
80}
81static inline u32 ccsr_channel_inst_bind_true_f(void)
82{
83 return 0x80000000;
84}
85static inline u32 ccsr_channel_r(u32 i)
86{
87 return 0x00800004 + i*8;
88}
89static inline u32 ccsr_channel__size_1_v(void)
90{
91 return 0x00000200;
92}
93static inline u32 ccsr_channel_enable_v(u32 r)
94{
95 return (r >> 0) & 0x1;
96}
97static inline u32 ccsr_channel_enable_set_f(u32 v)
98{
99 return (v & 0x1) << 10;
100}
101static inline u32 ccsr_channel_enable_set_true_f(void)
102{
103 return 0x400;
104}
105static inline u32 ccsr_channel_enable_clr_true_f(void)
106{
107 return 0x800;
108}
109static inline u32 ccsr_channel_status_v(u32 r)
110{
111 return (r >> 24) & 0xf;
112}
113static inline u32 ccsr_channel_busy_v(u32 r)
114{
115 return (r >> 28) & 0x1;
116}
117#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_ce_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_ce_gp10b.h
new file mode 100644
index 00000000..3f6e1470
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_ce_gp10b.h
@@ -0,0 +1,81 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ce_gp10b_h_
51#define _hw_ce_gp10b_h_
52
53static inline u32 ce_intr_status_r(u32 i)
54{
55 return 0x00104410 + i*128;
56}
57static inline u32 ce_intr_status_blockpipe_pending_f(void)
58{
59 return 0x1;
60}
61static inline u32 ce_intr_status_blockpipe_reset_f(void)
62{
63 return 0x1;
64}
65static inline u32 ce_intr_status_nonblockpipe_pending_f(void)
66{
67 return 0x2;
68}
69static inline u32 ce_intr_status_nonblockpipe_reset_f(void)
70{
71 return 0x2;
72}
73static inline u32 ce_intr_status_launcherr_pending_f(void)
74{
75 return 0x4;
76}
77static inline u32 ce_intr_status_launcherr_reset_f(void)
78{
79 return 0x4;
80}
81#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_chiplet_pwr_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_chiplet_pwr_gp10b.h
new file mode 100644
index 00000000..640453ce
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_chiplet_pwr_gp10b.h
@@ -0,0 +1,85 @@
1/*
2 * Copyright (c) 2014, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_chiplet_pwr_gp10b_h_
51#define _hw_chiplet_pwr_gp10b_h_
52
53static inline u32 chiplet_pwr_gpcs_weight_6_r(void)
54{
55 return 0x0010e018;
56}
57static inline u32 chiplet_pwr_gpcs_weight_7_r(void)
58{
59 return 0x0010e01c;
60}
61static inline u32 chiplet_pwr_gpcs_config_1_r(void)
62{
63 return 0x0010e03c;
64}
65static inline u32 chiplet_pwr_gpcs_config_1_ba_enable_yes_f(void)
66{
67 return 0x1;
68}
69static inline u32 chiplet_pwr_fbps_weight_0_r(void)
70{
71 return 0x0010e100;
72}
73static inline u32 chiplet_pwr_fbps_weight_1_r(void)
74{
75 return 0x0010e104;
76}
77static inline u32 chiplet_pwr_fbps_config_1_r(void)
78{
79 return 0x0010e13c;
80}
81static inline u32 chiplet_pwr_fbps_config_1_ba_enable_yes_f(void)
82{
83 return 0x1;
84}
85#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_ctxsw_prog_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_ctxsw_prog_gp10b.h
new file mode 100644
index 00000000..eef9a96f
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_ctxsw_prog_gp10b.h
@@ -0,0 +1,473 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ctxsw_prog_gp10b_h_
51#define _hw_ctxsw_prog_gp10b_h_
52
53static inline u32 ctxsw_prog_fecs_header_v(void)
54{
55 return 0x00000100;
56}
57static inline u32 ctxsw_prog_main_image_num_gpcs_o(void)
58{
59 return 0x00000008;
60}
61static inline u32 ctxsw_prog_main_image_patch_count_o(void)
62{
63 return 0x00000010;
64}
65static inline u32 ctxsw_prog_main_image_context_id_o(void)
66{
67 return 0x000000f0;
68}
69static inline u32 ctxsw_prog_main_image_patch_adr_lo_o(void)
70{
71 return 0x00000014;
72}
73static inline u32 ctxsw_prog_main_image_patch_adr_hi_o(void)
74{
75 return 0x00000018;
76}
77static inline u32 ctxsw_prog_main_image_zcull_o(void)
78{
79 return 0x0000001c;
80}
81static inline u32 ctxsw_prog_main_image_zcull_mode_no_ctxsw_v(void)
82{
83 return 0x00000001;
84}
85static inline u32 ctxsw_prog_main_image_zcull_mode_separate_buffer_v(void)
86{
87 return 0x00000002;
88}
89static inline u32 ctxsw_prog_main_image_zcull_ptr_o(void)
90{
91 return 0x00000020;
92}
93static inline u32 ctxsw_prog_main_image_pm_o(void)
94{
95 return 0x00000028;
96}
97static inline u32 ctxsw_prog_main_image_pm_mode_m(void)
98{
99 return 0x7 << 0;
100}
101static inline u32 ctxsw_prog_main_image_pm_mode_no_ctxsw_f(void)
102{
103 return 0x0;
104}
105static inline u32 ctxsw_prog_main_image_pm_smpc_mode_m(void)
106{
107 return 0x7 << 3;
108}
109static inline u32 ctxsw_prog_main_image_pm_smpc_mode_ctxsw_f(void)
110{
111 return 0x8;
112}
113static inline u32 ctxsw_prog_main_image_pm_smpc_mode_no_ctxsw_f(void)
114{
115 return 0x0;
116}
117static inline u32 ctxsw_prog_main_image_pm_ptr_o(void)
118{
119 return 0x0000002c;
120}
121static inline u32 ctxsw_prog_main_image_num_save_ops_o(void)
122{
123 return 0x000000f4;
124}
125static inline u32 ctxsw_prog_main_image_num_wfi_save_ops_o(void)
126{
127 return 0x000000d0;
128}
129static inline u32 ctxsw_prog_main_image_num_cta_save_ops_o(void)
130{
131 return 0x000000d4;
132}
133static inline u32 ctxsw_prog_main_image_num_gfxp_save_ops_o(void)
134{
135 return 0x000000d8;
136}
137static inline u32 ctxsw_prog_main_image_num_cilp_save_ops_o(void)
138{
139 return 0x000000dc;
140}
141static inline u32 ctxsw_prog_main_image_num_restore_ops_o(void)
142{
143 return 0x000000f8;
144}
145static inline u32 ctxsw_prog_main_image_magic_value_o(void)
146{
147 return 0x000000fc;
148}
149static inline u32 ctxsw_prog_main_image_magic_value_v_value_v(void)
150{
151 return 0x600dc0de;
152}
153static inline u32 ctxsw_prog_local_priv_register_ctl_o(void)
154{
155 return 0x0000000c;
156}
157static inline u32 ctxsw_prog_local_priv_register_ctl_offset_v(u32 r)
158{
159 return (r >> 0) & 0xffff;
160}
161static inline u32 ctxsw_prog_local_image_ppc_info_o(void)
162{
163 return 0x000000f4;
164}
165static inline u32 ctxsw_prog_local_image_ppc_info_num_ppcs_v(u32 r)
166{
167 return (r >> 0) & 0xffff;
168}
169static inline u32 ctxsw_prog_local_image_ppc_info_ppc_mask_v(u32 r)
170{
171 return (r >> 16) & 0xffff;
172}
173static inline u32 ctxsw_prog_local_image_num_tpcs_o(void)
174{
175 return 0x000000f8;
176}
177static inline u32 ctxsw_prog_local_magic_value_o(void)
178{
179 return 0x000000fc;
180}
181static inline u32 ctxsw_prog_local_magic_value_v_value_v(void)
182{
183 return 0xad0becab;
184}
185static inline u32 ctxsw_prog_main_extended_buffer_ctl_o(void)
186{
187 return 0x000000ec;
188}
189static inline u32 ctxsw_prog_main_extended_buffer_ctl_offset_v(u32 r)
190{
191 return (r >> 0) & 0xffff;
192}
193static inline u32 ctxsw_prog_main_extended_buffer_ctl_size_v(u32 r)
194{
195 return (r >> 16) & 0xff;
196}
197static inline u32 ctxsw_prog_extended_buffer_segments_size_in_bytes_v(void)
198{
199 return 0x00000100;
200}
201static inline u32 ctxsw_prog_extended_marker_size_in_bytes_v(void)
202{
203 return 0x00000004;
204}
205static inline u32 ctxsw_prog_extended_sm_dsm_perf_counter_register_stride_v(void)
206{
207 return 0x00000000;
208}
209static inline u32 ctxsw_prog_extended_sm_dsm_perf_counter_control_register_stride_v(void)
210{
211 return 0x00000002;
212}
213static inline u32 ctxsw_prog_main_image_priv_access_map_config_o(void)
214{
215 return 0x000000a0;
216}
217static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_s(void)
218{
219 return 2;
220}
221static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_f(u32 v)
222{
223 return (v & 0x3) << 0;
224}
225static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_m(void)
226{
227 return 0x3 << 0;
228}
229static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_v(u32 r)
230{
231 return (r >> 0) & 0x3;
232}
233static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_allow_all_f(void)
234{
235 return 0x0;
236}
237static inline u32 ctxsw_prog_main_image_priv_access_map_config_mode_use_map_f(void)
238{
239 return 0x2;
240}
241static inline u32 ctxsw_prog_main_image_priv_access_map_addr_lo_o(void)
242{
243 return 0x000000a4;
244}
245static inline u32 ctxsw_prog_main_image_priv_access_map_addr_hi_o(void)
246{
247 return 0x000000a8;
248}
249static inline u32 ctxsw_prog_main_image_misc_options_o(void)
250{
251 return 0x0000003c;
252}
253static inline u32 ctxsw_prog_main_image_misc_options_verif_features_m(void)
254{
255 return 0x1 << 3;
256}
257static inline u32 ctxsw_prog_main_image_misc_options_verif_features_disabled_f(void)
258{
259 return 0x0;
260}
261static inline u32 ctxsw_prog_main_image_graphics_preemption_options_o(void)
262{
263 return 0x00000080;
264}
265static inline u32 ctxsw_prog_main_image_graphics_preemption_options_control_f(u32 v)
266{
267 return (v & 0x3) << 0;
268}
269static inline u32 ctxsw_prog_main_image_graphics_preemption_options_control_gfxp_f(void)
270{
271 return 0x1;
272}
273static inline u32 ctxsw_prog_main_image_full_preemption_ptr_o(void)
274{
275 return 0x00000068;
276}
277static inline u32 ctxsw_prog_main_image_compute_preemption_options_o(void)
278{
279 return 0x00000084;
280}
281static inline u32 ctxsw_prog_main_image_compute_preemption_options_control_f(u32 v)
282{
283 return (v & 0x3) << 0;
284}
285static inline u32 ctxsw_prog_main_image_compute_preemption_options_control_cta_f(void)
286{
287 return 0x1;
288}
289static inline u32 ctxsw_prog_main_image_compute_preemption_options_control_cilp_f(void)
290{
291 return 0x2;
292}
293static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_control_o(void)
294{
295 return 0x000000ac;
296}
297static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_control_num_records_f(u32 v)
298{
299 return (v & 0xffff) << 0;
300}
301static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_o(void)
302{
303 return 0x000000b0;
304}
305static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_v_m(void)
306{
307 return 0xfffffff << 0;
308}
309static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_target_m(void)
310{
311 return 0x3 << 28;
312}
313static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_target_vid_mem_f(void)
314{
315 return 0x0;
316}
317static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_target_sys_mem_coherent_f(void)
318{
319 return 0x20000000;
320}
321static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_ptr_hi_target_sys_mem_noncoherent_f(void)
322{
323 return 0x30000000;
324}
325static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_ptr_o(void)
326{
327 return 0x000000b4;
328}
329static inline u32 ctxsw_prog_main_image_context_timestamp_buffer_ptr_v_f(u32 v)
330{
331 return (v & 0xffffffff) << 0;
332}
333static inline u32 ctxsw_prog_record_timestamp_record_size_in_bytes_v(void)
334{
335 return 0x00000080;
336}
337static inline u32 ctxsw_prog_record_timestamp_record_size_in_words_v(void)
338{
339 return 0x00000020;
340}
341static inline u32 ctxsw_prog_record_timestamp_magic_value_lo_o(void)
342{
343 return 0x00000000;
344}
345static inline u32 ctxsw_prog_record_timestamp_magic_value_lo_v_value_v(void)
346{
347 return 0x00000000;
348}
349static inline u32 ctxsw_prog_record_timestamp_magic_value_hi_o(void)
350{
351 return 0x00000004;
352}
353static inline u32 ctxsw_prog_record_timestamp_magic_value_hi_v_value_v(void)
354{
355 return 0x600dbeef;
356}
357static inline u32 ctxsw_prog_record_timestamp_context_id_o(void)
358{
359 return 0x00000008;
360}
361static inline u32 ctxsw_prog_record_timestamp_context_ptr_o(void)
362{
363 return 0x0000000c;
364}
365static inline u32 ctxsw_prog_record_timestamp_timestamp_lo_o(void)
366{
367 return 0x00000018;
368}
369static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_o(void)
370{
371 return 0x0000001c;
372}
373static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_v_f(u32 v)
374{
375 return (v & 0xffffff) << 0;
376}
377static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_v_v(u32 r)
378{
379 return (r >> 0) & 0xffffff;
380}
381static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_f(u32 v)
382{
383 return (v & 0xff) << 24;
384}
385static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_m(void)
386{
387 return 0xff << 24;
388}
389static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_v(u32 r)
390{
391 return (r >> 24) & 0xff;
392}
393static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_ctxsw_req_by_host_v(void)
394{
395 return 0x00000001;
396}
397static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_ctxsw_req_by_host_f(void)
398{
399 return 0x1000000;
400}
401static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_v(void)
402{
403 return 0x00000002;
404}
405static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_f(void)
406{
407 return 0x2000000;
408}
409static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_wfi_v(void)
410{
411 return 0x0000000a;
412}
413static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_wfi_f(void)
414{
415 return 0xa000000;
416}
417static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_gfxp_v(void)
418{
419 return 0x0000000b;
420}
421static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_gfxp_f(void)
422{
423 return 0xb000000;
424}
425static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_ctap_v(void)
426{
427 return 0x0000000c;
428}
429static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_ctap_f(void)
430{
431 return 0xc000000;
432}
433static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_cilp_v(void)
434{
435 return 0x0000000d;
436}
437static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_fe_ack_cilp_f(void)
438{
439 return 0xd000000;
440}
441static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_save_end_v(void)
442{
443 return 0x00000003;
444}
445static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_save_end_f(void)
446{
447 return 0x3000000;
448}
449static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_restore_start_v(void)
450{
451 return 0x00000004;
452}
453static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_restore_start_f(void)
454{
455 return 0x4000000;
456}
457static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_context_start_v(void)
458{
459 return 0x00000005;
460}
461static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_context_start_f(void)
462{
463 return 0x5000000;
464}
465static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_invalid_timestamp_v(void)
466{
467 return 0x000000ff;
468}
469static inline u32 ctxsw_prog_record_timestamp_timestamp_hi_tag_invalid_timestamp_f(void)
470{
471 return 0xff000000;
472}
473#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_fb_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_fb_gp10b.h
new file mode 100644
index 00000000..ec340777
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_fb_gp10b.h
@@ -0,0 +1,481 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_fb_gp10b_h_
51#define _hw_fb_gp10b_h_
52
53static inline u32 fb_fbhub_num_active_ltcs_r(void)
54{
55 return 0x00100800;
56}
57static inline u32 fb_mmu_ctrl_r(void)
58{
59 return 0x00100c80;
60}
61static inline u32 fb_mmu_ctrl_vm_pg_size_f(u32 v)
62{
63 return (v & 0x1) << 0;
64}
65static inline u32 fb_mmu_ctrl_vm_pg_size_128kb_f(void)
66{
67 return 0x0;
68}
69static inline u32 fb_mmu_ctrl_vm_pg_size_64kb_f(void)
70{
71 return 0x1;
72}
73static inline u32 fb_mmu_ctrl_pri_fifo_empty_v(u32 r)
74{
75 return (r >> 15) & 0x1;
76}
77static inline u32 fb_mmu_ctrl_pri_fifo_empty_false_f(void)
78{
79 return 0x0;
80}
81static inline u32 fb_mmu_ctrl_pri_fifo_space_v(u32 r)
82{
83 return (r >> 16) & 0xff;
84}
85static inline u32 fb_mmu_ctrl_use_pdb_big_page_size_v(u32 r)
86{
87 return (r >> 11) & 0x1;
88}
89static inline u32 fb_mmu_ctrl_use_pdb_big_page_size_true_f(void)
90{
91 return 0x800;
92}
93static inline u32 fb_mmu_ctrl_use_pdb_big_page_size_false_f(void)
94{
95 return 0x0;
96}
97static inline u32 fb_priv_mmu_phy_secure_r(void)
98{
99 return 0x00100ce4;
100}
101static inline u32 fb_mmu_invalidate_pdb_r(void)
102{
103 return 0x00100cb8;
104}
105static inline u32 fb_mmu_invalidate_pdb_aperture_vid_mem_f(void)
106{
107 return 0x0;
108}
109static inline u32 fb_mmu_invalidate_pdb_aperture_sys_mem_f(void)
110{
111 return 0x2;
112}
113static inline u32 fb_mmu_invalidate_pdb_addr_f(u32 v)
114{
115 return (v & 0xfffffff) << 4;
116}
117static inline u32 fb_mmu_invalidate_r(void)
118{
119 return 0x00100cbc;
120}
121static inline u32 fb_mmu_invalidate_all_va_true_f(void)
122{
123 return 0x1;
124}
125static inline u32 fb_mmu_invalidate_all_pdb_true_f(void)
126{
127 return 0x2;
128}
129static inline u32 fb_mmu_invalidate_hubtlb_only_s(void)
130{
131 return 1;
132}
133static inline u32 fb_mmu_invalidate_hubtlb_only_f(u32 v)
134{
135 return (v & 0x1) << 2;
136}
137static inline u32 fb_mmu_invalidate_hubtlb_only_m(void)
138{
139 return 0x1 << 2;
140}
141static inline u32 fb_mmu_invalidate_hubtlb_only_v(u32 r)
142{
143 return (r >> 2) & 0x1;
144}
145static inline u32 fb_mmu_invalidate_hubtlb_only_true_f(void)
146{
147 return 0x4;
148}
149static inline u32 fb_mmu_invalidate_replay_s(void)
150{
151 return 3;
152}
153static inline u32 fb_mmu_invalidate_replay_f(u32 v)
154{
155 return (v & 0x7) << 3;
156}
157static inline u32 fb_mmu_invalidate_replay_m(void)
158{
159 return 0x7 << 3;
160}
161static inline u32 fb_mmu_invalidate_replay_v(u32 r)
162{
163 return (r >> 3) & 0x7;
164}
165static inline u32 fb_mmu_invalidate_replay_none_f(void)
166{
167 return 0x0;
168}
169static inline u32 fb_mmu_invalidate_replay_start_f(void)
170{
171 return 0x8;
172}
173static inline u32 fb_mmu_invalidate_replay_start_ack_all_f(void)
174{
175 return 0x10;
176}
177static inline u32 fb_mmu_invalidate_replay_cancel_targeted_f(void)
178{
179 return 0x18;
180}
181static inline u32 fb_mmu_invalidate_replay_cancel_global_f(void)
182{
183 return 0x20;
184}
185static inline u32 fb_mmu_invalidate_replay_cancel_f(void)
186{
187 return 0x20;
188}
189static inline u32 fb_mmu_invalidate_sys_membar_s(void)
190{
191 return 1;
192}
193static inline u32 fb_mmu_invalidate_sys_membar_f(u32 v)
194{
195 return (v & 0x1) << 6;
196}
197static inline u32 fb_mmu_invalidate_sys_membar_m(void)
198{
199 return 0x1 << 6;
200}
201static inline u32 fb_mmu_invalidate_sys_membar_v(u32 r)
202{
203 return (r >> 6) & 0x1;
204}
205static inline u32 fb_mmu_invalidate_sys_membar_true_f(void)
206{
207 return 0x40;
208}
209static inline u32 fb_mmu_invalidate_ack_s(void)
210{
211 return 2;
212}
213static inline u32 fb_mmu_invalidate_ack_f(u32 v)
214{
215 return (v & 0x3) << 7;
216}
217static inline u32 fb_mmu_invalidate_ack_m(void)
218{
219 return 0x3 << 7;
220}
221static inline u32 fb_mmu_invalidate_ack_v(u32 r)
222{
223 return (r >> 7) & 0x3;
224}
225static inline u32 fb_mmu_invalidate_ack_ack_none_required_f(void)
226{
227 return 0x0;
228}
229static inline u32 fb_mmu_invalidate_ack_ack_intranode_f(void)
230{
231 return 0x100;
232}
233static inline u32 fb_mmu_invalidate_ack_ack_globally_f(void)
234{
235 return 0x80;
236}
237static inline u32 fb_mmu_invalidate_cancel_client_id_s(void)
238{
239 return 6;
240}
241static inline u32 fb_mmu_invalidate_cancel_client_id_f(u32 v)
242{
243 return (v & 0x3f) << 9;
244}
245static inline u32 fb_mmu_invalidate_cancel_client_id_m(void)
246{
247 return 0x3f << 9;
248}
249static inline u32 fb_mmu_invalidate_cancel_client_id_v(u32 r)
250{
251 return (r >> 9) & 0x3f;
252}
253static inline u32 fb_mmu_invalidate_cancel_gpc_id_s(void)
254{
255 return 5;
256}
257static inline u32 fb_mmu_invalidate_cancel_gpc_id_f(u32 v)
258{
259 return (v & 0x1f) << 15;
260}
261static inline u32 fb_mmu_invalidate_cancel_gpc_id_m(void)
262{
263 return 0x1f << 15;
264}
265static inline u32 fb_mmu_invalidate_cancel_gpc_id_v(u32 r)
266{
267 return (r >> 15) & 0x1f;
268}
269static inline u32 fb_mmu_invalidate_cancel_client_type_s(void)
270{
271 return 1;
272}
273static inline u32 fb_mmu_invalidate_cancel_client_type_f(u32 v)
274{
275 return (v & 0x1) << 20;
276}
277static inline u32 fb_mmu_invalidate_cancel_client_type_m(void)
278{
279 return 0x1 << 20;
280}
281static inline u32 fb_mmu_invalidate_cancel_client_type_v(u32 r)
282{
283 return (r >> 20) & 0x1;
284}
285static inline u32 fb_mmu_invalidate_cancel_client_type_gpc_f(void)
286{
287 return 0x0;
288}
289static inline u32 fb_mmu_invalidate_cancel_client_type_hub_f(void)
290{
291 return 0x100000;
292}
293static inline u32 fb_mmu_invalidate_cancel_cache_level_s(void)
294{
295 return 3;
296}
297static inline u32 fb_mmu_invalidate_cancel_cache_level_f(u32 v)
298{
299 return (v & 0x7) << 24;
300}
301static inline u32 fb_mmu_invalidate_cancel_cache_level_m(void)
302{
303 return 0x7 << 24;
304}
305static inline u32 fb_mmu_invalidate_cancel_cache_level_v(u32 r)
306{
307 return (r >> 24) & 0x7;
308}
309static inline u32 fb_mmu_invalidate_cancel_cache_level_all_f(void)
310{
311 return 0x0;
312}
313static inline u32 fb_mmu_invalidate_cancel_cache_level_pte_only_f(void)
314{
315 return 0x1000000;
316}
317static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde0_f(void)
318{
319 return 0x2000000;
320}
321static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde1_f(void)
322{
323 return 0x3000000;
324}
325static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde2_f(void)
326{
327 return 0x4000000;
328}
329static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde3_f(void)
330{
331 return 0x5000000;
332}
333static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde4_f(void)
334{
335 return 0x6000000;
336}
337static inline u32 fb_mmu_invalidate_cancel_cache_level_up_to_pde5_f(void)
338{
339 return 0x7000000;
340}
341static inline u32 fb_mmu_invalidate_trigger_s(void)
342{
343 return 1;
344}
345static inline u32 fb_mmu_invalidate_trigger_f(u32 v)
346{
347 return (v & 0x1) << 31;
348}
349static inline u32 fb_mmu_invalidate_trigger_m(void)
350{
351 return 0x1 << 31;
352}
353static inline u32 fb_mmu_invalidate_trigger_v(u32 r)
354{
355 return (r >> 31) & 0x1;
356}
357static inline u32 fb_mmu_invalidate_trigger_true_f(void)
358{
359 return 0x80000000;
360}
361static inline u32 fb_mmu_debug_wr_r(void)
362{
363 return 0x00100cc8;
364}
365static inline u32 fb_mmu_debug_wr_aperture_s(void)
366{
367 return 2;
368}
369static inline u32 fb_mmu_debug_wr_aperture_f(u32 v)
370{
371 return (v & 0x3) << 0;
372}
373static inline u32 fb_mmu_debug_wr_aperture_m(void)
374{
375 return 0x3 << 0;
376}
377static inline u32 fb_mmu_debug_wr_aperture_v(u32 r)
378{
379 return (r >> 0) & 0x3;
380}
381static inline u32 fb_mmu_debug_wr_aperture_vid_mem_f(void)
382{
383 return 0x0;
384}
385static inline u32 fb_mmu_debug_wr_aperture_sys_mem_coh_f(void)
386{
387 return 0x2;
388}
389static inline u32 fb_mmu_debug_wr_aperture_sys_mem_ncoh_f(void)
390{
391 return 0x3;
392}
393static inline u32 fb_mmu_debug_wr_vol_false_f(void)
394{
395 return 0x0;
396}
397static inline u32 fb_mmu_debug_wr_vol_true_v(void)
398{
399 return 0x00000001;
400}
401static inline u32 fb_mmu_debug_wr_vol_true_f(void)
402{
403 return 0x4;
404}
405static inline u32 fb_mmu_debug_wr_addr_f(u32 v)
406{
407 return (v & 0xfffffff) << 4;
408}
409static inline u32 fb_mmu_debug_wr_addr_alignment_v(void)
410{
411 return 0x0000000c;
412}
413static inline u32 fb_mmu_debug_rd_r(void)
414{
415 return 0x00100ccc;
416}
417static inline u32 fb_mmu_debug_rd_aperture_vid_mem_f(void)
418{
419 return 0x0;
420}
421static inline u32 fb_mmu_debug_rd_aperture_sys_mem_coh_f(void)
422{
423 return 0x2;
424}
425static inline u32 fb_mmu_debug_rd_aperture_sys_mem_ncoh_f(void)
426{
427 return 0x3;
428}
429static inline u32 fb_mmu_debug_rd_vol_false_f(void)
430{
431 return 0x0;
432}
433static inline u32 fb_mmu_debug_rd_addr_f(u32 v)
434{
435 return (v & 0xfffffff) << 4;
436}
437static inline u32 fb_mmu_debug_rd_addr_alignment_v(void)
438{
439 return 0x0000000c;
440}
441static inline u32 fb_mmu_debug_ctrl_r(void)
442{
443 return 0x00100cc4;
444}
445static inline u32 fb_mmu_debug_ctrl_debug_v(u32 r)
446{
447 return (r >> 16) & 0x1;
448}
449static inline u32 fb_mmu_debug_ctrl_debug_m(void)
450{
451 return 0x1 << 16;
452}
453static inline u32 fb_mmu_debug_ctrl_debug_enabled_v(void)
454{
455 return 0x00000001;
456}
457static inline u32 fb_mmu_debug_ctrl_debug_disabled_v(void)
458{
459 return 0x00000000;
460}
461static inline u32 fb_mmu_vpr_info_r(void)
462{
463 return 0x00100cd0;
464}
465static inline u32 fb_mmu_vpr_info_fetch_v(u32 r)
466{
467 return (r >> 2) & 0x1;
468}
469static inline u32 fb_mmu_vpr_info_fetch_false_v(void)
470{
471 return 0x00000000;
472}
473static inline u32 fb_mmu_vpr_info_fetch_true_v(void)
474{
475 return 0x00000001;
476}
477static inline u32 fb_niso_flush_sysmem_addr_r(void)
478{
479 return 0x00100c10;
480}
481#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_fifo_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_fifo_gp10b.h
new file mode 100644
index 00000000..8370d4c6
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_fifo_gp10b.h
@@ -0,0 +1,689 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_fifo_gp10b_h_
51#define _hw_fifo_gp10b_h_
52
53static inline u32 fifo_bar1_base_r(void)
54{
55 return 0x00002254;
56}
57static inline u32 fifo_bar1_base_ptr_f(u32 v)
58{
59 return (v & 0xfffffff) << 0;
60}
61static inline u32 fifo_bar1_base_ptr_align_shift_v(void)
62{
63 return 0x0000000c;
64}
65static inline u32 fifo_bar1_base_valid_false_f(void)
66{
67 return 0x0;
68}
69static inline u32 fifo_bar1_base_valid_true_f(void)
70{
71 return 0x10000000;
72}
73static inline u32 fifo_runlist_base_r(void)
74{
75 return 0x00002270;
76}
77static inline u32 fifo_runlist_base_ptr_f(u32 v)
78{
79 return (v & 0xfffffff) << 0;
80}
81static inline u32 fifo_runlist_base_target_vid_mem_f(void)
82{
83 return 0x0;
84}
85static inline u32 fifo_runlist_base_target_sys_mem_coh_f(void)
86{
87 return 0x20000000;
88}
89static inline u32 fifo_runlist_base_target_sys_mem_ncoh_f(void)
90{
91 return 0x30000000;
92}
93static inline u32 fifo_runlist_r(void)
94{
95 return 0x00002274;
96}
97static inline u32 fifo_runlist_engine_f(u32 v)
98{
99 return (v & 0xf) << 20;
100}
101static inline u32 fifo_eng_runlist_base_r(u32 i)
102{
103 return 0x00002280 + i*8;
104}
105static inline u32 fifo_eng_runlist_base__size_1_v(void)
106{
107 return 0x00000001;
108}
109static inline u32 fifo_eng_runlist_r(u32 i)
110{
111 return 0x00002284 + i*8;
112}
113static inline u32 fifo_eng_runlist__size_1_v(void)
114{
115 return 0x00000001;
116}
117static inline u32 fifo_eng_runlist_length_f(u32 v)
118{
119 return (v & 0xffff) << 0;
120}
121static inline u32 fifo_eng_runlist_length_max_v(void)
122{
123 return 0x0000ffff;
124}
125static inline u32 fifo_eng_runlist_pending_true_f(void)
126{
127 return 0x100000;
128}
129static inline u32 fifo_pb_timeslice_r(u32 i)
130{
131 return 0x00002350 + i*4;
132}
133static inline u32 fifo_pb_timeslice_timeout_16_f(void)
134{
135 return 0x10;
136}
137static inline u32 fifo_pb_timeslice_timescale_0_f(void)
138{
139 return 0x0;
140}
141static inline u32 fifo_pb_timeslice_enable_true_f(void)
142{
143 return 0x10000000;
144}
145static inline u32 fifo_pbdma_map_r(u32 i)
146{
147 return 0x00002390 + i*4;
148}
149static inline u32 fifo_intr_0_r(void)
150{
151 return 0x00002100;
152}
153static inline u32 fifo_intr_0_bind_error_pending_f(void)
154{
155 return 0x1;
156}
157static inline u32 fifo_intr_0_bind_error_reset_f(void)
158{
159 return 0x1;
160}
161static inline u32 fifo_intr_0_sched_error_pending_f(void)
162{
163 return 0x100;
164}
165static inline u32 fifo_intr_0_sched_error_reset_f(void)
166{
167 return 0x100;
168}
169static inline u32 fifo_intr_0_chsw_error_pending_f(void)
170{
171 return 0x10000;
172}
173static inline u32 fifo_intr_0_chsw_error_reset_f(void)
174{
175 return 0x10000;
176}
177static inline u32 fifo_intr_0_fb_flush_timeout_pending_f(void)
178{
179 return 0x800000;
180}
181static inline u32 fifo_intr_0_fb_flush_timeout_reset_f(void)
182{
183 return 0x800000;
184}
185static inline u32 fifo_intr_0_lb_error_pending_f(void)
186{
187 return 0x1000000;
188}
189static inline u32 fifo_intr_0_lb_error_reset_f(void)
190{
191 return 0x1000000;
192}
193static inline u32 fifo_intr_0_replayable_fault_error_pending_f(void)
194{
195 return 0x2000000;
196}
197static inline u32 fifo_intr_0_dropped_mmu_fault_pending_f(void)
198{
199 return 0x8000000;
200}
201static inline u32 fifo_intr_0_dropped_mmu_fault_reset_f(void)
202{
203 return 0x8000000;
204}
205static inline u32 fifo_intr_0_mmu_fault_pending_f(void)
206{
207 return 0x10000000;
208}
209static inline u32 fifo_intr_0_pbdma_intr_pending_f(void)
210{
211 return 0x20000000;
212}
213static inline u32 fifo_intr_0_runlist_event_pending_f(void)
214{
215 return 0x40000000;
216}
217static inline u32 fifo_intr_0_channel_intr_pending_f(void)
218{
219 return 0x80000000;
220}
221static inline u32 fifo_intr_en_0_r(void)
222{
223 return 0x00002140;
224}
225static inline u32 fifo_intr_en_0_sched_error_f(u32 v)
226{
227 return (v & 0x1) << 8;
228}
229static inline u32 fifo_intr_en_0_sched_error_m(void)
230{
231 return 0x1 << 8;
232}
233static inline u32 fifo_intr_en_0_mmu_fault_f(u32 v)
234{
235 return (v & 0x1) << 28;
236}
237static inline u32 fifo_intr_en_0_mmu_fault_m(void)
238{
239 return 0x1 << 28;
240}
241static inline u32 fifo_intr_en_1_r(void)
242{
243 return 0x00002528;
244}
245static inline u32 fifo_intr_bind_error_r(void)
246{
247 return 0x0000252c;
248}
249static inline u32 fifo_intr_sched_error_r(void)
250{
251 return 0x0000254c;
252}
253static inline u32 fifo_intr_sched_error_code_f(u32 v)
254{
255 return (v & 0xff) << 0;
256}
257static inline u32 fifo_intr_sched_error_code_ctxsw_timeout_v(void)
258{
259 return 0x0000000a;
260}
261static inline u32 fifo_intr_chsw_error_r(void)
262{
263 return 0x0000256c;
264}
265static inline u32 fifo_intr_mmu_fault_id_r(void)
266{
267 return 0x0000259c;
268}
269static inline u32 fifo_intr_mmu_fault_eng_id_graphics_v(void)
270{
271 return 0x00000000;
272}
273static inline u32 fifo_intr_mmu_fault_eng_id_graphics_f(void)
274{
275 return 0x0;
276}
277static inline u32 fifo_intr_mmu_fault_inst_r(u32 i)
278{
279 return 0x00002800 + i*16;
280}
281static inline u32 fifo_intr_mmu_fault_inst_ptr_v(u32 r)
282{
283 return (r >> 0) & 0xfffffff;
284}
285static inline u32 fifo_intr_mmu_fault_inst_ptr_align_shift_v(void)
286{
287 return 0x0000000c;
288}
289static inline u32 fifo_intr_mmu_fault_lo_r(u32 i)
290{
291 return 0x00002804 + i*16;
292}
293static inline u32 fifo_intr_mmu_fault_hi_r(u32 i)
294{
295 return 0x00002808 + i*16;
296}
297static inline u32 fifo_intr_mmu_fault_info_r(u32 i)
298{
299 return 0x0000280c + i*16;
300}
301static inline u32 fifo_intr_mmu_fault_info_type_v(u32 r)
302{
303 return (r >> 0) & 0x1f;
304}
305static inline u32 fifo_intr_mmu_fault_info_client_type_v(u32 r)
306{
307 return (r >> 20) & 0x1;
308}
309static inline u32 fifo_intr_mmu_fault_info_client_type_gpc_v(void)
310{
311 return 0x00000000;
312}
313static inline u32 fifo_intr_mmu_fault_info_client_type_hub_v(void)
314{
315 return 0x00000001;
316}
317static inline u32 fifo_intr_mmu_fault_info_client_v(u32 r)
318{
319 return (r >> 8) & 0x7f;
320}
321static inline u32 fifo_intr_pbdma_id_r(void)
322{
323 return 0x000025a0;
324}
325static inline u32 fifo_intr_pbdma_id_status_f(u32 v, u32 i)
326{
327 return (v & 0x1) << (0 + i*1);
328}
329static inline u32 fifo_intr_pbdma_id_status_v(u32 r, u32 i)
330{
331 return (r >> (0 + i*1)) & 0x1;
332}
333static inline u32 fifo_intr_pbdma_id_status__size_1_v(void)
334{
335 return 0x00000001;
336}
337static inline u32 fifo_intr_runlist_r(void)
338{
339 return 0x00002a00;
340}
341static inline u32 fifo_fb_timeout_r(void)
342{
343 return 0x00002a04;
344}
345static inline u32 fifo_fb_timeout_period_m(void)
346{
347 return 0x3fffffff << 0;
348}
349static inline u32 fifo_fb_timeout_period_max_f(void)
350{
351 return 0x3fffffff;
352}
353static inline u32 fifo_error_sched_disable_r(void)
354{
355 return 0x0000262c;
356}
357static inline u32 fifo_sched_disable_r(void)
358{
359 return 0x00002630;
360}
361static inline u32 fifo_sched_disable_runlist_f(u32 v, u32 i)
362{
363 return (v & 0x1) << (0 + i*1);
364}
365static inline u32 fifo_sched_disable_runlist_m(u32 i)
366{
367 return 0x1 << (0 + i*1);
368}
369static inline u32 fifo_sched_disable_true_v(void)
370{
371 return 0x00000001;
372}
373static inline u32 fifo_preempt_r(void)
374{
375 return 0x00002634;
376}
377static inline u32 fifo_preempt_pending_true_f(void)
378{
379 return 0x100000;
380}
381static inline u32 fifo_preempt_type_channel_f(void)
382{
383 return 0x0;
384}
385static inline u32 fifo_preempt_type_tsg_f(void)
386{
387 return 0x1000000;
388}
389static inline u32 fifo_preempt_chid_f(u32 v)
390{
391 return (v & 0xfff) << 0;
392}
393static inline u32 fifo_preempt_id_f(u32 v)
394{
395 return (v & 0xfff) << 0;
396}
397static inline u32 fifo_trigger_mmu_fault_r(u32 i)
398{
399 return 0x00002a30 + i*4;
400}
401static inline u32 fifo_trigger_mmu_fault_id_f(u32 v)
402{
403 return (v & 0x1f) << 0;
404}
405static inline u32 fifo_trigger_mmu_fault_enable_f(u32 v)
406{
407 return (v & 0x1) << 8;
408}
409static inline u32 fifo_engine_status_r(u32 i)
410{
411 return 0x00002640 + i*8;
412}
413static inline u32 fifo_engine_status__size_1_v(void)
414{
415 return 0x00000002;
416}
417static inline u32 fifo_engine_status_id_v(u32 r)
418{
419 return (r >> 0) & 0xfff;
420}
421static inline u32 fifo_engine_status_id_type_v(u32 r)
422{
423 return (r >> 12) & 0x1;
424}
425static inline u32 fifo_engine_status_id_type_chid_v(void)
426{
427 return 0x00000000;
428}
429static inline u32 fifo_engine_status_id_type_tsgid_v(void)
430{
431 return 0x00000001;
432}
433static inline u32 fifo_engine_status_ctx_status_v(u32 r)
434{
435 return (r >> 13) & 0x7;
436}
437static inline u32 fifo_engine_status_ctx_status_invalid_v(void)
438{
439 return 0x00000000;
440}
441static inline u32 fifo_engine_status_ctx_status_valid_v(void)
442{
443 return 0x00000001;
444}
445static inline u32 fifo_engine_status_ctx_status_ctxsw_load_v(void)
446{
447 return 0x00000005;
448}
449static inline u32 fifo_engine_status_ctx_status_ctxsw_save_v(void)
450{
451 return 0x00000006;
452}
453static inline u32 fifo_engine_status_ctx_status_ctxsw_switch_v(void)
454{
455 return 0x00000007;
456}
457static inline u32 fifo_engine_status_next_id_v(u32 r)
458{
459 return (r >> 16) & 0xfff;
460}
461static inline u32 fifo_engine_status_next_id_type_v(u32 r)
462{
463 return (r >> 28) & 0x1;
464}
465static inline u32 fifo_engine_status_next_id_type_chid_v(void)
466{
467 return 0x00000000;
468}
469static inline u32 fifo_engine_status_faulted_v(u32 r)
470{
471 return (r >> 30) & 0x1;
472}
473static inline u32 fifo_engine_status_faulted_true_v(void)
474{
475 return 0x00000001;
476}
477static inline u32 fifo_engine_status_engine_v(u32 r)
478{
479 return (r >> 31) & 0x1;
480}
481static inline u32 fifo_engine_status_engine_idle_v(void)
482{
483 return 0x00000000;
484}
485static inline u32 fifo_engine_status_engine_busy_v(void)
486{
487 return 0x00000001;
488}
489static inline u32 fifo_engine_status_ctxsw_v(u32 r)
490{
491 return (r >> 15) & 0x1;
492}
493static inline u32 fifo_engine_status_ctxsw_in_progress_v(void)
494{
495 return 0x00000001;
496}
497static inline u32 fifo_engine_status_ctxsw_in_progress_f(void)
498{
499 return 0x8000;
500}
501static inline u32 fifo_pbdma_status_r(u32 i)
502{
503 return 0x00003080 + i*4;
504}
505static inline u32 fifo_pbdma_status__size_1_v(void)
506{
507 return 0x00000001;
508}
509static inline u32 fifo_pbdma_status_id_v(u32 r)
510{
511 return (r >> 0) & 0xfff;
512}
513static inline u32 fifo_pbdma_status_id_type_v(u32 r)
514{
515 return (r >> 12) & 0x1;
516}
517static inline u32 fifo_pbdma_status_id_type_chid_v(void)
518{
519 return 0x00000000;
520}
521static inline u32 fifo_pbdma_status_id_type_tsgid_v(void)
522{
523 return 0x00000001;
524}
525static inline u32 fifo_pbdma_status_chan_status_v(u32 r)
526{
527 return (r >> 13) & 0x7;
528}
529static inline u32 fifo_pbdma_status_chan_status_valid_v(void)
530{
531 return 0x00000001;
532}
533static inline u32 fifo_pbdma_status_chan_status_chsw_load_v(void)
534{
535 return 0x00000005;
536}
537static inline u32 fifo_pbdma_status_chan_status_chsw_save_v(void)
538{
539 return 0x00000006;
540}
541static inline u32 fifo_pbdma_status_chan_status_chsw_switch_v(void)
542{
543 return 0x00000007;
544}
545static inline u32 fifo_pbdma_status_next_id_v(u32 r)
546{
547 return (r >> 16) & 0xfff;
548}
549static inline u32 fifo_pbdma_status_next_id_type_v(u32 r)
550{
551 return (r >> 28) & 0x1;
552}
553static inline u32 fifo_pbdma_status_next_id_type_chid_v(void)
554{
555 return 0x00000000;
556}
557static inline u32 fifo_pbdma_status_chsw_v(u32 r)
558{
559 return (r >> 15) & 0x1;
560}
561static inline u32 fifo_pbdma_status_chsw_in_progress_v(void)
562{
563 return 0x00000001;
564}
565static inline u32 fifo_replay_fault_buffer_lo_r(void)
566{
567 return 0x00002a70;
568}
569static inline u32 fifo_replay_fault_buffer_lo_enable_v(u32 r)
570{
571 return (r >> 0) & 0x1;
572}
573static inline u32 fifo_replay_fault_buffer_lo_enable_true_v(void)
574{
575 return 0x00000001;
576}
577static inline u32 fifo_replay_fault_buffer_lo_enable_false_v(void)
578{
579 return 0x00000000;
580}
581static inline u32 fifo_replay_fault_buffer_lo_base_f(u32 v)
582{
583 return (v & 0xfffff) << 12;
584}
585static inline u32 fifo_replay_fault_buffer_lo_base_reset_v(void)
586{
587 return 0x00000000;
588}
589static inline u32 fifo_replay_fault_buffer_hi_r(void)
590{
591 return 0x00002a74;
592}
593static inline u32 fifo_replay_fault_buffer_hi_base_f(u32 v)
594{
595 return (v & 0xff) << 0;
596}
597static inline u32 fifo_replay_fault_buffer_hi_base_reset_v(void)
598{
599 return 0x00000000;
600}
601static inline u32 fifo_replay_fault_buffer_size_r(void)
602{
603 return 0x00002a78;
604}
605static inline u32 fifo_replay_fault_buffer_size_hw_f(u32 v)
606{
607 return (v & 0x1ff) << 0;
608}
609static inline u32 fifo_replay_fault_buffer_size_hw_entries_v(void)
610{
611 return 0x000000c0;
612}
613static inline u32 fifo_replay_fault_buffer_get_r(void)
614{
615 return 0x00002a7c;
616}
617static inline u32 fifo_replay_fault_buffer_get_offset_hw_f(u32 v)
618{
619 return (v & 0x1ff) << 0;
620}
621static inline u32 fifo_replay_fault_buffer_get_offset_hw_init_v(void)
622{
623 return 0x00000000;
624}
625static inline u32 fifo_replay_fault_buffer_put_r(void)
626{
627 return 0x00002a80;
628}
629static inline u32 fifo_replay_fault_buffer_put_offset_hw_f(u32 v)
630{
631 return (v & 0x1ff) << 0;
632}
633static inline u32 fifo_replay_fault_buffer_put_offset_hw_init_v(void)
634{
635 return 0x00000000;
636}
637static inline u32 fifo_replay_fault_buffer_info_r(void)
638{
639 return 0x00002a84;
640}
641static inline u32 fifo_replay_fault_buffer_info_overflow_f(u32 v)
642{
643 return (v & 0x1) << 0;
644}
645static inline u32 fifo_replay_fault_buffer_info_overflow_false_v(void)
646{
647 return 0x00000000;
648}
649static inline u32 fifo_replay_fault_buffer_info_overflow_true_v(void)
650{
651 return 0x00000001;
652}
653static inline u32 fifo_replay_fault_buffer_info_overflow_clear_v(void)
654{
655 return 0x00000001;
656}
657static inline u32 fifo_replay_fault_buffer_info_write_nack_f(u32 v)
658{
659 return (v & 0x1) << 24;
660}
661static inline u32 fifo_replay_fault_buffer_info_write_nack_false_v(void)
662{
663 return 0x00000000;
664}
665static inline u32 fifo_replay_fault_buffer_info_write_nack_true_v(void)
666{
667 return 0x00000001;
668}
669static inline u32 fifo_replay_fault_buffer_info_write_nack_clear_v(void)
670{
671 return 0x00000001;
672}
673static inline u32 fifo_replay_fault_buffer_info_fault_while_buffer_disabled_f(u32 v)
674{
675 return (v & 0x1) << 28;
676}
677static inline u32 fifo_replay_fault_buffer_info_fault_while_buffer_disabled_false_v(void)
678{
679 return 0x00000000;
680}
681static inline u32 fifo_replay_fault_buffer_info_fault_while_buffer_disabled_true_v(void)
682{
683 return 0x00000001;
684}
685static inline u32 fifo_replay_fault_buffer_info_fault_while_buffer_disabled_clear_v(void)
686{
687 return 0x00000001;
688}
689#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_flush_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_flush_gp10b.h
new file mode 100644
index 00000000..e2dff490
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_flush_gp10b.h
@@ -0,0 +1,181 @@
1/*
2 * Copyright (c) 2014-2015, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_flush_gp10b_h_
51#define _hw_flush_gp10b_h_
52
53static inline u32 flush_l2_system_invalidate_r(void)
54{
55 return 0x00070004;
56}
57static inline u32 flush_l2_system_invalidate_pending_v(u32 r)
58{
59 return (r >> 0) & 0x1;
60}
61static inline u32 flush_l2_system_invalidate_pending_busy_v(void)
62{
63 return 0x00000001;
64}
65static inline u32 flush_l2_system_invalidate_pending_busy_f(void)
66{
67 return 0x1;
68}
69static inline u32 flush_l2_system_invalidate_outstanding_v(u32 r)
70{
71 return (r >> 1) & 0x1;
72}
73static inline u32 flush_l2_system_invalidate_outstanding_true_v(void)
74{
75 return 0x00000001;
76}
77static inline u32 flush_l2_flush_dirty_r(void)
78{
79 return 0x00070010;
80}
81static inline u32 flush_l2_flush_dirty_pending_v(u32 r)
82{
83 return (r >> 0) & 0x1;
84}
85static inline u32 flush_l2_flush_dirty_pending_empty_v(void)
86{
87 return 0x00000000;
88}
89static inline u32 flush_l2_flush_dirty_pending_empty_f(void)
90{
91 return 0x0;
92}
93static inline u32 flush_l2_flush_dirty_pending_busy_v(void)
94{
95 return 0x00000001;
96}
97static inline u32 flush_l2_flush_dirty_pending_busy_f(void)
98{
99 return 0x1;
100}
101static inline u32 flush_l2_flush_dirty_outstanding_v(u32 r)
102{
103 return (r >> 1) & 0x1;
104}
105static inline u32 flush_l2_flush_dirty_outstanding_false_v(void)
106{
107 return 0x00000000;
108}
109static inline u32 flush_l2_flush_dirty_outstanding_false_f(void)
110{
111 return 0x0;
112}
113static inline u32 flush_l2_flush_dirty_outstanding_true_v(void)
114{
115 return 0x00000001;
116}
117static inline u32 flush_l2_clean_comptags_r(void)
118{
119 return 0x0007000c;
120}
121static inline u32 flush_l2_clean_comptags_pending_v(u32 r)
122{
123 return (r >> 0) & 0x1;
124}
125static inline u32 flush_l2_clean_comptags_pending_empty_v(void)
126{
127 return 0x00000000;
128}
129static inline u32 flush_l2_clean_comptags_pending_empty_f(void)
130{
131 return 0x0;
132}
133static inline u32 flush_l2_clean_comptags_pending_busy_v(void)
134{
135 return 0x00000001;
136}
137static inline u32 flush_l2_clean_comptags_pending_busy_f(void)
138{
139 return 0x1;
140}
141static inline u32 flush_l2_clean_comptags_outstanding_v(u32 r)
142{
143 return (r >> 1) & 0x1;
144}
145static inline u32 flush_l2_clean_comptags_outstanding_false_v(void)
146{
147 return 0x00000000;
148}
149static inline u32 flush_l2_clean_comptags_outstanding_false_f(void)
150{
151 return 0x0;
152}
153static inline u32 flush_l2_clean_comptags_outstanding_true_v(void)
154{
155 return 0x00000001;
156}
157static inline u32 flush_fb_flush_r(void)
158{
159 return 0x00070000;
160}
161static inline u32 flush_fb_flush_pending_v(u32 r)
162{
163 return (r >> 0) & 0x1;
164}
165static inline u32 flush_fb_flush_pending_busy_v(void)
166{
167 return 0x00000001;
168}
169static inline u32 flush_fb_flush_pending_busy_f(void)
170{
171 return 0x1;
172}
173static inline u32 flush_fb_flush_outstanding_v(u32 r)
174{
175 return (r >> 1) & 0x1;
176}
177static inline u32 flush_fb_flush_outstanding_true_v(void)
178{
179 return 0x00000001;
180}
181#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_fuse_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_fuse_gp10b.h
new file mode 100644
index 00000000..2b1acf2f
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_fuse_gp10b.h
@@ -0,0 +1,145 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_fuse_gp10b_h_
51#define _hw_fuse_gp10b_h_
52
53static inline u32 fuse_status_opt_tpc_gpc_r(u32 i)
54{
55 return 0x00021c38 + i*4;
56}
57static inline u32 fuse_ctrl_opt_tpc_gpc_r(u32 i)
58{
59 return 0x00021838 + i*4;
60}
61static inline u32 fuse_ctrl_opt_ram_svop_pdp_r(void)
62{
63 return 0x00021944;
64}
65static inline u32 fuse_ctrl_opt_ram_svop_pdp_data_f(u32 v)
66{
67 return (v & 0xff) << 0;
68}
69static inline u32 fuse_ctrl_opt_ram_svop_pdp_data_m(void)
70{
71 return 0xff << 0;
72}
73static inline u32 fuse_ctrl_opt_ram_svop_pdp_data_v(u32 r)
74{
75 return (r >> 0) & 0xff;
76}
77static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_r(void)
78{
79 return 0x00021948;
80}
81static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_f(u32 v)
82{
83 return (v & 0x1) << 0;
84}
85static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_m(void)
86{
87 return 0x1 << 0;
88}
89static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_v(u32 r)
90{
91 return (r >> 0) & 0x1;
92}
93static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_yes_f(void)
94{
95 return 0x1;
96}
97static inline u32 fuse_ctrl_opt_ram_svop_pdp_override_data_no_f(void)
98{
99 return 0x0;
100}
101static inline u32 fuse_status_opt_fbio_r(void)
102{
103 return 0x00021c14;
104}
105static inline u32 fuse_status_opt_fbio_data_f(u32 v)
106{
107 return (v & 0xffff) << 0;
108}
109static inline u32 fuse_status_opt_fbio_data_m(void)
110{
111 return 0xffff << 0;
112}
113static inline u32 fuse_status_opt_fbio_data_v(u32 r)
114{
115 return (r >> 0) & 0xffff;
116}
117static inline u32 fuse_status_opt_rop_l2_fbp_r(u32 i)
118{
119 return 0x00021d70 + i*4;
120}
121static inline u32 fuse_status_opt_fbp_r(void)
122{
123 return 0x00021d38;
124}
125static inline u32 fuse_status_opt_fbp_idx_v(u32 r, u32 i)
126{
127 return (r >> (0 + i*0)) & 0x1;
128}
129static inline u32 fuse_opt_ecc_en_r(void)
130{
131 return 0x00021228;
132}
133static inline u32 fuse_opt_feature_fuses_override_disable_r(void)
134{
135 return 0x000213f0;
136}
137static inline u32 fuse_opt_sec_debug_en_r(void)
138{
139 return 0x00021218;
140}
141static inline u32 fuse_opt_priv_sec_en_r(void)
142{
143 return 0x00021434;
144}
145#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_gmmu_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_gmmu_gp10b.h
new file mode 100644
index 00000000..d231ee44
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_gmmu_gp10b.h
@@ -0,0 +1,1277 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_gmmu_gp10b_h_
51#define _hw_gmmu_gp10b_h_
52
53static inline u32 gmmu_new_pde_is_pte_w(void)
54{
55 return 0;
56}
57static inline u32 gmmu_new_pde_is_pte_false_f(void)
58{
59 return 0x0;
60}
61static inline u32 gmmu_new_pde_aperture_w(void)
62{
63 return 0;
64}
65static inline u32 gmmu_new_pde_aperture_invalid_f(void)
66{
67 return 0x0;
68}
69static inline u32 gmmu_new_pde_aperture_video_memory_f(void)
70{
71 return 0x2;
72}
73static inline u32 gmmu_new_pde_aperture_sys_mem_coh_f(void)
74{
75 return 0x4;
76}
77static inline u32 gmmu_new_pde_aperture_sys_mem_ncoh_f(void)
78{
79 return 0x6;
80}
81static inline u32 gmmu_new_pde_address_sys_f(u32 v)
82{
83 return (v & 0xfffffff) << 8;
84}
85static inline u32 gmmu_new_pde_address_sys_w(void)
86{
87 return 0;
88}
89static inline u32 gmmu_new_pde_vol_w(void)
90{
91 return 0;
92}
93static inline u32 gmmu_new_pde_vol_true_f(void)
94{
95 return 0x8;
96}
97static inline u32 gmmu_new_pde_vol_false_f(void)
98{
99 return 0x0;
100}
101static inline u32 gmmu_new_pde_address_shift_v(void)
102{
103 return 0x0000000c;
104}
105static inline u32 gmmu_new_pde__size_v(void)
106{
107 return 0x00000008;
108}
109static inline u32 gmmu_new_dual_pde_is_pte_w(void)
110{
111 return 0;
112}
113static inline u32 gmmu_new_dual_pde_is_pte_false_f(void)
114{
115 return 0x0;
116}
117static inline u32 gmmu_new_dual_pde_aperture_big_w(void)
118{
119 return 0;
120}
121static inline u32 gmmu_new_dual_pde_aperture_big_invalid_f(void)
122{
123 return 0x0;
124}
125static inline u32 gmmu_new_dual_pde_aperture_big_video_memory_f(void)
126{
127 return 0x2;
128}
129static inline u32 gmmu_new_dual_pde_aperture_big_sys_mem_coh_f(void)
130{
131 return 0x4;
132}
133static inline u32 gmmu_new_dual_pde_aperture_big_sys_mem_ncoh_f(void)
134{
135 return 0x6;
136}
137static inline u32 gmmu_new_dual_pde_address_big_sys_f(u32 v)
138{
139 return (v & 0xfffffff) << 4;
140}
141static inline u32 gmmu_new_dual_pde_address_big_sys_w(void)
142{
143 return 0;
144}
145static inline u32 gmmu_new_dual_pde_aperture_small_w(void)
146{
147 return 2;
148}
149static inline u32 gmmu_new_dual_pde_aperture_small_invalid_f(void)
150{
151 return 0x0;
152}
153static inline u32 gmmu_new_dual_pde_aperture_small_video_memory_f(void)
154{
155 return 0x2;
156}
157static inline u32 gmmu_new_dual_pde_aperture_small_sys_mem_coh_f(void)
158{
159 return 0x4;
160}
161static inline u32 gmmu_new_dual_pde_aperture_small_sys_mem_ncoh_f(void)
162{
163 return 0x6;
164}
165static inline u32 gmmu_new_dual_pde_vol_small_w(void)
166{
167 return 2;
168}
169static inline u32 gmmu_new_dual_pde_vol_small_true_f(void)
170{
171 return 0x8;
172}
173static inline u32 gmmu_new_dual_pde_vol_small_false_f(void)
174{
175 return 0x0;
176}
177static inline u32 gmmu_new_dual_pde_vol_big_w(void)
178{
179 return 0;
180}
181static inline u32 gmmu_new_dual_pde_vol_big_true_f(void)
182{
183 return 0x8;
184}
185static inline u32 gmmu_new_dual_pde_vol_big_false_f(void)
186{
187 return 0x0;
188}
189static inline u32 gmmu_new_dual_pde_address_small_sys_f(u32 v)
190{
191 return (v & 0xfffffff) << 8;
192}
193static inline u32 gmmu_new_dual_pde_address_small_sys_w(void)
194{
195 return 2;
196}
197static inline u32 gmmu_new_dual_pde_address_shift_v(void)
198{
199 return 0x0000000c;
200}
201static inline u32 gmmu_new_dual_pde_address_big_shift_v(void)
202{
203 return 0x00000008;
204}
205static inline u32 gmmu_new_dual_pde__size_v(void)
206{
207 return 0x00000010;
208}
209static inline u32 gmmu_new_pte__size_v(void)
210{
211 return 0x00000008;
212}
213static inline u32 gmmu_new_pte_valid_w(void)
214{
215 return 0;
216}
217static inline u32 gmmu_new_pte_valid_true_f(void)
218{
219 return 0x1;
220}
221static inline u32 gmmu_new_pte_valid_false_f(void)
222{
223 return 0x0;
224}
225static inline u32 gmmu_new_pte_privilege_w(void)
226{
227 return 0;
228}
229static inline u32 gmmu_new_pte_privilege_true_f(void)
230{
231 return 0x20;
232}
233static inline u32 gmmu_new_pte_privilege_false_f(void)
234{
235 return 0x0;
236}
237static inline u32 gmmu_new_pte_address_sys_f(u32 v)
238{
239 return (v & 0xfffffff) << 8;
240}
241static inline u32 gmmu_new_pte_address_sys_w(void)
242{
243 return 0;
244}
245static inline u32 gmmu_new_pte_address_vid_f(u32 v)
246{
247 return (v & 0xffffff) << 8;
248}
249static inline u32 gmmu_new_pte_address_vid_w(void)
250{
251 return 0;
252}
253static inline u32 gmmu_new_pte_vol_w(void)
254{
255 return 0;
256}
257static inline u32 gmmu_new_pte_vol_true_f(void)
258{
259 return 0x8;
260}
261static inline u32 gmmu_new_pte_vol_false_f(void)
262{
263 return 0x0;
264}
265static inline u32 gmmu_new_pte_aperture_w(void)
266{
267 return 0;
268}
269static inline u32 gmmu_new_pte_aperture_video_memory_f(void)
270{
271 return 0x0;
272}
273static inline u32 gmmu_new_pte_aperture_sys_mem_coh_f(void)
274{
275 return 0x4;
276}
277static inline u32 gmmu_new_pte_aperture_sys_mem_ncoh_f(void)
278{
279 return 0x6;
280}
281static inline u32 gmmu_new_pte_read_only_w(void)
282{
283 return 0;
284}
285static inline u32 gmmu_new_pte_read_only_true_f(void)
286{
287 return 0x40;
288}
289static inline u32 gmmu_new_pte_comptagline_f(u32 v)
290{
291 return (v & 0x3ffff) << 4;
292}
293static inline u32 gmmu_new_pte_comptagline_w(void)
294{
295 return 1;
296}
297static inline u32 gmmu_new_pte_kind_f(u32 v)
298{
299 return (v & 0xff) << 24;
300}
301static inline u32 gmmu_new_pte_kind_w(void)
302{
303 return 1;
304}
305static inline u32 gmmu_new_pte_address_shift_v(void)
306{
307 return 0x0000000c;
308}
309static inline u32 gmmu_pte_kind_f(u32 v)
310{
311 return (v & 0xff) << 4;
312}
313static inline u32 gmmu_pte_kind_w(void)
314{
315 return 1;
316}
317static inline u32 gmmu_pte_kind_invalid_v(void)
318{
319 return 0x000000ff;
320}
321static inline u32 gmmu_pte_kind_pitch_v(void)
322{
323 return 0x00000000;
324}
325static inline u32 gmmu_pte_kind_z16_v(void)
326{
327 return 0x00000001;
328}
329static inline u32 gmmu_pte_kind_z16_2c_v(void)
330{
331 return 0x00000002;
332}
333static inline u32 gmmu_pte_kind_z16_ms2_2c_v(void)
334{
335 return 0x00000003;
336}
337static inline u32 gmmu_pte_kind_z16_ms4_2c_v(void)
338{
339 return 0x00000004;
340}
341static inline u32 gmmu_pte_kind_z16_ms8_2c_v(void)
342{
343 return 0x00000005;
344}
345static inline u32 gmmu_pte_kind_z16_ms16_2c_v(void)
346{
347 return 0x00000006;
348}
349static inline u32 gmmu_pte_kind_z16_2z_v(void)
350{
351 return 0x00000007;
352}
353static inline u32 gmmu_pte_kind_z16_ms2_2z_v(void)
354{
355 return 0x00000008;
356}
357static inline u32 gmmu_pte_kind_z16_ms4_2z_v(void)
358{
359 return 0x00000009;
360}
361static inline u32 gmmu_pte_kind_z16_ms8_2z_v(void)
362{
363 return 0x0000000a;
364}
365static inline u32 gmmu_pte_kind_z16_ms16_2z_v(void)
366{
367 return 0x0000000b;
368}
369static inline u32 gmmu_pte_kind_z16_2cz_v(void)
370{
371 return 0x00000036;
372}
373static inline u32 gmmu_pte_kind_z16_ms2_2cz_v(void)
374{
375 return 0x00000037;
376}
377static inline u32 gmmu_pte_kind_z16_ms4_2cz_v(void)
378{
379 return 0x00000038;
380}
381static inline u32 gmmu_pte_kind_z16_ms8_2cz_v(void)
382{
383 return 0x00000039;
384}
385static inline u32 gmmu_pte_kind_z16_ms16_2cz_v(void)
386{
387 return 0x0000005f;
388}
389static inline u32 gmmu_pte_kind_z16_4cz_v(void)
390{
391 return 0x0000000c;
392}
393static inline u32 gmmu_pte_kind_z16_ms2_4cz_v(void)
394{
395 return 0x0000000d;
396}
397static inline u32 gmmu_pte_kind_z16_ms4_4cz_v(void)
398{
399 return 0x0000000e;
400}
401static inline u32 gmmu_pte_kind_z16_ms8_4cz_v(void)
402{
403 return 0x0000000f;
404}
405static inline u32 gmmu_pte_kind_z16_ms16_4cz_v(void)
406{
407 return 0x00000010;
408}
409static inline u32 gmmu_pte_kind_s8z24_v(void)
410{
411 return 0x00000011;
412}
413static inline u32 gmmu_pte_kind_s8z24_1z_v(void)
414{
415 return 0x00000012;
416}
417static inline u32 gmmu_pte_kind_s8z24_ms2_1z_v(void)
418{
419 return 0x00000013;
420}
421static inline u32 gmmu_pte_kind_s8z24_ms4_1z_v(void)
422{
423 return 0x00000014;
424}
425static inline u32 gmmu_pte_kind_s8z24_ms8_1z_v(void)
426{
427 return 0x00000015;
428}
429static inline u32 gmmu_pte_kind_s8z24_ms16_1z_v(void)
430{
431 return 0x00000016;
432}
433static inline u32 gmmu_pte_kind_s8z24_2cz_v(void)
434{
435 return 0x00000017;
436}
437static inline u32 gmmu_pte_kind_s8z24_ms2_2cz_v(void)
438{
439 return 0x00000018;
440}
441static inline u32 gmmu_pte_kind_s8z24_ms4_2cz_v(void)
442{
443 return 0x00000019;
444}
445static inline u32 gmmu_pte_kind_s8z24_ms8_2cz_v(void)
446{
447 return 0x0000001a;
448}
449static inline u32 gmmu_pte_kind_s8z24_ms16_2cz_v(void)
450{
451 return 0x0000001b;
452}
453static inline u32 gmmu_pte_kind_s8z24_2cs_v(void)
454{
455 return 0x0000001c;
456}
457static inline u32 gmmu_pte_kind_s8z24_ms2_2cs_v(void)
458{
459 return 0x0000001d;
460}
461static inline u32 gmmu_pte_kind_s8z24_ms4_2cs_v(void)
462{
463 return 0x0000001e;
464}
465static inline u32 gmmu_pte_kind_s8z24_ms8_2cs_v(void)
466{
467 return 0x0000001f;
468}
469static inline u32 gmmu_pte_kind_s8z24_ms16_2cs_v(void)
470{
471 return 0x00000020;
472}
473static inline u32 gmmu_pte_kind_s8z24_4cszv_v(void)
474{
475 return 0x00000021;
476}
477static inline u32 gmmu_pte_kind_s8z24_ms2_4cszv_v(void)
478{
479 return 0x00000022;
480}
481static inline u32 gmmu_pte_kind_s8z24_ms4_4cszv_v(void)
482{
483 return 0x00000023;
484}
485static inline u32 gmmu_pte_kind_s8z24_ms8_4cszv_v(void)
486{
487 return 0x00000024;
488}
489static inline u32 gmmu_pte_kind_s8z24_ms16_4cszv_v(void)
490{
491 return 0x00000025;
492}
493static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_v(void)
494{
495 return 0x00000026;
496}
497static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_v(void)
498{
499 return 0x00000027;
500}
501static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_v(void)
502{
503 return 0x00000028;
504}
505static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_v(void)
506{
507 return 0x00000029;
508}
509static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_1zv_v(void)
510{
511 return 0x0000002e;
512}
513static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_1zv_v(void)
514{
515 return 0x0000002f;
516}
517static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_1zv_v(void)
518{
519 return 0x00000030;
520}
521static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_1zv_v(void)
522{
523 return 0x00000031;
524}
525static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_2cs_v(void)
526{
527 return 0x00000032;
528}
529static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_2cs_v(void)
530{
531 return 0x00000033;
532}
533static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_2cs_v(void)
534{
535 return 0x00000034;
536}
537static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_2cs_v(void)
538{
539 return 0x00000035;
540}
541static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_2czv_v(void)
542{
543 return 0x0000003a;
544}
545static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_2czv_v(void)
546{
547 return 0x0000003b;
548}
549static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_2czv_v(void)
550{
551 return 0x0000003c;
552}
553static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_2czv_v(void)
554{
555 return 0x0000003d;
556}
557static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_2zv_v(void)
558{
559 return 0x0000003e;
560}
561static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_2zv_v(void)
562{
563 return 0x0000003f;
564}
565static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_2zv_v(void)
566{
567 return 0x00000040;
568}
569static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_2zv_v(void)
570{
571 return 0x00000041;
572}
573static inline u32 gmmu_pte_kind_v8z24_ms4_vc12_4cszv_v(void)
574{
575 return 0x00000042;
576}
577static inline u32 gmmu_pte_kind_v8z24_ms4_vc4_4cszv_v(void)
578{
579 return 0x00000043;
580}
581static inline u32 gmmu_pte_kind_v8z24_ms8_vc8_4cszv_v(void)
582{
583 return 0x00000044;
584}
585static inline u32 gmmu_pte_kind_v8z24_ms8_vc24_4cszv_v(void)
586{
587 return 0x00000045;
588}
589static inline u32 gmmu_pte_kind_z24s8_v(void)
590{
591 return 0x00000046;
592}
593static inline u32 gmmu_pte_kind_z24s8_1z_v(void)
594{
595 return 0x00000047;
596}
597static inline u32 gmmu_pte_kind_z24s8_ms2_1z_v(void)
598{
599 return 0x00000048;
600}
601static inline u32 gmmu_pte_kind_z24s8_ms4_1z_v(void)
602{
603 return 0x00000049;
604}
605static inline u32 gmmu_pte_kind_z24s8_ms8_1z_v(void)
606{
607 return 0x0000004a;
608}
609static inline u32 gmmu_pte_kind_z24s8_ms16_1z_v(void)
610{
611 return 0x0000004b;
612}
613static inline u32 gmmu_pte_kind_z24s8_2cs_v(void)
614{
615 return 0x0000004c;
616}
617static inline u32 gmmu_pte_kind_z24s8_ms2_2cs_v(void)
618{
619 return 0x0000004d;
620}
621static inline u32 gmmu_pte_kind_z24s8_ms4_2cs_v(void)
622{
623 return 0x0000004e;
624}
625static inline u32 gmmu_pte_kind_z24s8_ms8_2cs_v(void)
626{
627 return 0x0000004f;
628}
629static inline u32 gmmu_pte_kind_z24s8_ms16_2cs_v(void)
630{
631 return 0x00000050;
632}
633static inline u32 gmmu_pte_kind_z24s8_2cz_v(void)
634{
635 return 0x00000051;
636}
637static inline u32 gmmu_pte_kind_z24s8_ms2_2cz_v(void)
638{
639 return 0x00000052;
640}
641static inline u32 gmmu_pte_kind_z24s8_ms4_2cz_v(void)
642{
643 return 0x00000053;
644}
645static inline u32 gmmu_pte_kind_z24s8_ms8_2cz_v(void)
646{
647 return 0x00000054;
648}
649static inline u32 gmmu_pte_kind_z24s8_ms16_2cz_v(void)
650{
651 return 0x00000055;
652}
653static inline u32 gmmu_pte_kind_z24s8_4cszv_v(void)
654{
655 return 0x00000056;
656}
657static inline u32 gmmu_pte_kind_z24s8_ms2_4cszv_v(void)
658{
659 return 0x00000057;
660}
661static inline u32 gmmu_pte_kind_z24s8_ms4_4cszv_v(void)
662{
663 return 0x00000058;
664}
665static inline u32 gmmu_pte_kind_z24s8_ms8_4cszv_v(void)
666{
667 return 0x00000059;
668}
669static inline u32 gmmu_pte_kind_z24s8_ms16_4cszv_v(void)
670{
671 return 0x0000005a;
672}
673static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_v(void)
674{
675 return 0x0000005b;
676}
677static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_v(void)
678{
679 return 0x0000005c;
680}
681static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_v(void)
682{
683 return 0x0000005d;
684}
685static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_v(void)
686{
687 return 0x0000005e;
688}
689static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_1zv_v(void)
690{
691 return 0x00000063;
692}
693static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_1zv_v(void)
694{
695 return 0x00000064;
696}
697static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_1zv_v(void)
698{
699 return 0x00000065;
700}
701static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_1zv_v(void)
702{
703 return 0x00000066;
704}
705static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_2cs_v(void)
706{
707 return 0x00000067;
708}
709static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_2cs_v(void)
710{
711 return 0x00000068;
712}
713static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_2cs_v(void)
714{
715 return 0x00000069;
716}
717static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_2cs_v(void)
718{
719 return 0x0000006a;
720}
721static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_2czv_v(void)
722{
723 return 0x0000006f;
724}
725static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_2czv_v(void)
726{
727 return 0x00000070;
728}
729static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_2czv_v(void)
730{
731 return 0x00000071;
732}
733static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_2czv_v(void)
734{
735 return 0x00000072;
736}
737static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_2zv_v(void)
738{
739 return 0x00000073;
740}
741static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_2zv_v(void)
742{
743 return 0x00000074;
744}
745static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_2zv_v(void)
746{
747 return 0x00000075;
748}
749static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_2zv_v(void)
750{
751 return 0x00000076;
752}
753static inline u32 gmmu_pte_kind_z24v8_ms4_vc12_4cszv_v(void)
754{
755 return 0x00000077;
756}
757static inline u32 gmmu_pte_kind_z24v8_ms4_vc4_4cszv_v(void)
758{
759 return 0x00000078;
760}
761static inline u32 gmmu_pte_kind_z24v8_ms8_vc8_4cszv_v(void)
762{
763 return 0x00000079;
764}
765static inline u32 gmmu_pte_kind_z24v8_ms8_vc24_4cszv_v(void)
766{
767 return 0x0000007a;
768}
769static inline u32 gmmu_pte_kind_zf32_v(void)
770{
771 return 0x0000007b;
772}
773static inline u32 gmmu_pte_kind_zf32_1z_v(void)
774{
775 return 0x0000007c;
776}
777static inline u32 gmmu_pte_kind_zf32_ms2_1z_v(void)
778{
779 return 0x0000007d;
780}
781static inline u32 gmmu_pte_kind_zf32_ms4_1z_v(void)
782{
783 return 0x0000007e;
784}
785static inline u32 gmmu_pte_kind_zf32_ms8_1z_v(void)
786{
787 return 0x0000007f;
788}
789static inline u32 gmmu_pte_kind_zf32_ms16_1z_v(void)
790{
791 return 0x00000080;
792}
793static inline u32 gmmu_pte_kind_zf32_2cs_v(void)
794{
795 return 0x00000081;
796}
797static inline u32 gmmu_pte_kind_zf32_ms2_2cs_v(void)
798{
799 return 0x00000082;
800}
801static inline u32 gmmu_pte_kind_zf32_ms4_2cs_v(void)
802{
803 return 0x00000083;
804}
805static inline u32 gmmu_pte_kind_zf32_ms8_2cs_v(void)
806{
807 return 0x00000084;
808}
809static inline u32 gmmu_pte_kind_zf32_ms16_2cs_v(void)
810{
811 return 0x00000085;
812}
813static inline u32 gmmu_pte_kind_zf32_2cz_v(void)
814{
815 return 0x00000086;
816}
817static inline u32 gmmu_pte_kind_zf32_ms2_2cz_v(void)
818{
819 return 0x00000087;
820}
821static inline u32 gmmu_pte_kind_zf32_ms4_2cz_v(void)
822{
823 return 0x00000088;
824}
825static inline u32 gmmu_pte_kind_zf32_ms8_2cz_v(void)
826{
827 return 0x00000089;
828}
829static inline u32 gmmu_pte_kind_zf32_ms16_2cz_v(void)
830{
831 return 0x0000008a;
832}
833static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_v(void)
834{
835 return 0x0000008b;
836}
837static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_v(void)
838{
839 return 0x0000008c;
840}
841static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_v(void)
842{
843 return 0x0000008d;
844}
845static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_v(void)
846{
847 return 0x0000008e;
848}
849static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_1cs_v(void)
850{
851 return 0x0000008f;
852}
853static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_1cs_v(void)
854{
855 return 0x00000090;
856}
857static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_1cs_v(void)
858{
859 return 0x00000091;
860}
861static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_1cs_v(void)
862{
863 return 0x00000092;
864}
865static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_1zv_v(void)
866{
867 return 0x00000097;
868}
869static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_1zv_v(void)
870{
871 return 0x00000098;
872}
873static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_1zv_v(void)
874{
875 return 0x00000099;
876}
877static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_1zv_v(void)
878{
879 return 0x0000009a;
880}
881static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_1czv_v(void)
882{
883 return 0x0000009b;
884}
885static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_1czv_v(void)
886{
887 return 0x0000009c;
888}
889static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_1czv_v(void)
890{
891 return 0x0000009d;
892}
893static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_1czv_v(void)
894{
895 return 0x0000009e;
896}
897static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_2cs_v(void)
898{
899 return 0x0000009f;
900}
901static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_2cs_v(void)
902{
903 return 0x000000a0;
904}
905static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_2cs_v(void)
906{
907 return 0x000000a1;
908}
909static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_2cs_v(void)
910{
911 return 0x000000a2;
912}
913static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc12_2cszv_v(void)
914{
915 return 0x000000a3;
916}
917static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms4_vc4_2cszv_v(void)
918{
919 return 0x000000a4;
920}
921static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc8_2cszv_v(void)
922{
923 return 0x000000a5;
924}
925static inline u32 gmmu_pte_kind_x8z24_x16v8s8_ms8_vc24_2cszv_v(void)
926{
927 return 0x000000a6;
928}
929static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_v(void)
930{
931 return 0x000000a7;
932}
933static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_v(void)
934{
935 return 0x000000a8;
936}
937static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_v(void)
938{
939 return 0x000000a9;
940}
941static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_v(void)
942{
943 return 0x000000aa;
944}
945static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_1cs_v(void)
946{
947 return 0x000000ab;
948}
949static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_1cs_v(void)
950{
951 return 0x000000ac;
952}
953static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_1cs_v(void)
954{
955 return 0x000000ad;
956}
957static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_1cs_v(void)
958{
959 return 0x000000ae;
960}
961static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_1zv_v(void)
962{
963 return 0x000000b3;
964}
965static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_1zv_v(void)
966{
967 return 0x000000b4;
968}
969static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_1zv_v(void)
970{
971 return 0x000000b5;
972}
973static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_1zv_v(void)
974{
975 return 0x000000b6;
976}
977static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_1czv_v(void)
978{
979 return 0x000000b7;
980}
981static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_1czv_v(void)
982{
983 return 0x000000b8;
984}
985static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_1czv_v(void)
986{
987 return 0x000000b9;
988}
989static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_1czv_v(void)
990{
991 return 0x000000ba;
992}
993static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_2cs_v(void)
994{
995 return 0x000000bb;
996}
997static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_2cs_v(void)
998{
999 return 0x000000bc;
1000}
1001static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_2cs_v(void)
1002{
1003 return 0x000000bd;
1004}
1005static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_2cs_v(void)
1006{
1007 return 0x000000be;
1008}
1009static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc12_2cszv_v(void)
1010{
1011 return 0x000000bf;
1012}
1013static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms4_vc4_2cszv_v(void)
1014{
1015 return 0x000000c0;
1016}
1017static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc8_2cszv_v(void)
1018{
1019 return 0x000000c1;
1020}
1021static inline u32 gmmu_pte_kind_zf32_x16v8s8_ms8_vc24_2cszv_v(void)
1022{
1023 return 0x000000c2;
1024}
1025static inline u32 gmmu_pte_kind_zf32_x24s8_v(void)
1026{
1027 return 0x000000c3;
1028}
1029static inline u32 gmmu_pte_kind_zf32_x24s8_1cs_v(void)
1030{
1031 return 0x000000c4;
1032}
1033static inline u32 gmmu_pte_kind_zf32_x24s8_ms2_1cs_v(void)
1034{
1035 return 0x000000c5;
1036}
1037static inline u32 gmmu_pte_kind_zf32_x24s8_ms4_1cs_v(void)
1038{
1039 return 0x000000c6;
1040}
1041static inline u32 gmmu_pte_kind_zf32_x24s8_ms8_1cs_v(void)
1042{
1043 return 0x000000c7;
1044}
1045static inline u32 gmmu_pte_kind_zf32_x24s8_ms16_1cs_v(void)
1046{
1047 return 0x000000c8;
1048}
1049static inline u32 gmmu_pte_kind_zf32_x24s8_2cszv_v(void)
1050{
1051 return 0x000000ce;
1052}
1053static inline u32 gmmu_pte_kind_zf32_x24s8_ms2_2cszv_v(void)
1054{
1055 return 0x000000cf;
1056}
1057static inline u32 gmmu_pte_kind_zf32_x24s8_ms4_2cszv_v(void)
1058{
1059 return 0x000000d0;
1060}
1061static inline u32 gmmu_pte_kind_zf32_x24s8_ms8_2cszv_v(void)
1062{
1063 return 0x000000d1;
1064}
1065static inline u32 gmmu_pte_kind_zf32_x24s8_ms16_2cszv_v(void)
1066{
1067 return 0x000000d2;
1068}
1069static inline u32 gmmu_pte_kind_zf32_x24s8_2cs_v(void)
1070{
1071 return 0x000000d3;
1072}
1073static inline u32 gmmu_pte_kind_zf32_x24s8_ms2_2cs_v(void)
1074{
1075 return 0x000000d4;
1076}
1077static inline u32 gmmu_pte_kind_zf32_x24s8_ms4_2cs_v(void)
1078{
1079 return 0x000000d5;
1080}
1081static inline u32 gmmu_pte_kind_zf32_x24s8_ms8_2cs_v(void)
1082{
1083 return 0x000000d6;
1084}
1085static inline u32 gmmu_pte_kind_zf32_x24s8_ms16_2cs_v(void)
1086{
1087 return 0x000000d7;
1088}
1089static inline u32 gmmu_pte_kind_generic_16bx2_v(void)
1090{
1091 return 0x000000fe;
1092}
1093static inline u32 gmmu_pte_kind_c32_2c_v(void)
1094{
1095 return 0x000000d8;
1096}
1097static inline u32 gmmu_pte_kind_c32_2cbr_v(void)
1098{
1099 return 0x000000d9;
1100}
1101static inline u32 gmmu_pte_kind_c32_2cba_v(void)
1102{
1103 return 0x000000da;
1104}
1105static inline u32 gmmu_pte_kind_c32_2cra_v(void)
1106{
1107 return 0x000000db;
1108}
1109static inline u32 gmmu_pte_kind_c32_2bra_v(void)
1110{
1111 return 0x000000dc;
1112}
1113static inline u32 gmmu_pte_kind_c32_ms2_2c_v(void)
1114{
1115 return 0x000000dd;
1116}
1117static inline u32 gmmu_pte_kind_c32_ms2_2cbr_v(void)
1118{
1119 return 0x000000de;
1120}
1121static inline u32 gmmu_pte_kind_c32_ms2_2cra_v(void)
1122{
1123 return 0x000000cc;
1124}
1125static inline u32 gmmu_pte_kind_c32_ms4_2c_v(void)
1126{
1127 return 0x000000df;
1128}
1129static inline u32 gmmu_pte_kind_c32_ms4_2cbr_v(void)
1130{
1131 return 0x000000e0;
1132}
1133static inline u32 gmmu_pte_kind_c32_ms4_2cba_v(void)
1134{
1135 return 0x000000e1;
1136}
1137static inline u32 gmmu_pte_kind_c32_ms4_2cra_v(void)
1138{
1139 return 0x000000e2;
1140}
1141static inline u32 gmmu_pte_kind_c32_ms4_2bra_v(void)
1142{
1143 return 0x000000e3;
1144}
1145static inline u32 gmmu_pte_kind_c32_ms4_4cbra_v(void)
1146{
1147 return 0x0000002c;
1148}
1149static inline u32 gmmu_pte_kind_c32_ms8_ms16_2c_v(void)
1150{
1151 return 0x000000e4;
1152}
1153static inline u32 gmmu_pte_kind_c32_ms8_ms16_2cra_v(void)
1154{
1155 return 0x000000e5;
1156}
1157static inline u32 gmmu_pte_kind_c64_2c_v(void)
1158{
1159 return 0x000000e6;
1160}
1161static inline u32 gmmu_pte_kind_c64_2cbr_v(void)
1162{
1163 return 0x000000e7;
1164}
1165static inline u32 gmmu_pte_kind_c64_2cba_v(void)
1166{
1167 return 0x000000e8;
1168}
1169static inline u32 gmmu_pte_kind_c64_2cra_v(void)
1170{
1171 return 0x000000e9;
1172}
1173static inline u32 gmmu_pte_kind_c64_2bra_v(void)
1174{
1175 return 0x000000ea;
1176}
1177static inline u32 gmmu_pte_kind_c64_ms2_2c_v(void)
1178{
1179 return 0x000000eb;
1180}
1181static inline u32 gmmu_pte_kind_c64_ms2_2cbr_v(void)
1182{
1183 return 0x000000ec;
1184}
1185static inline u32 gmmu_pte_kind_c64_ms2_2cra_v(void)
1186{
1187 return 0x000000cd;
1188}
1189static inline u32 gmmu_pte_kind_c64_ms4_2c_v(void)
1190{
1191 return 0x000000ed;
1192}
1193static inline u32 gmmu_pte_kind_c64_ms4_2cbr_v(void)
1194{
1195 return 0x000000ee;
1196}
1197static inline u32 gmmu_pte_kind_c64_ms4_2cba_v(void)
1198{
1199 return 0x000000ef;
1200}
1201static inline u32 gmmu_pte_kind_c64_ms4_2cra_v(void)
1202{
1203 return 0x000000f0;
1204}
1205static inline u32 gmmu_pte_kind_c64_ms4_2bra_v(void)
1206{
1207 return 0x000000f1;
1208}
1209static inline u32 gmmu_pte_kind_c64_ms4_4cbra_v(void)
1210{
1211 return 0x0000002d;
1212}
1213static inline u32 gmmu_pte_kind_c64_ms8_ms16_2c_v(void)
1214{
1215 return 0x000000f2;
1216}
1217static inline u32 gmmu_pte_kind_c64_ms8_ms16_2cra_v(void)
1218{
1219 return 0x000000f3;
1220}
1221static inline u32 gmmu_pte_kind_c128_2c_v(void)
1222{
1223 return 0x000000f4;
1224}
1225static inline u32 gmmu_pte_kind_c128_2cr_v(void)
1226{
1227 return 0x000000f5;
1228}
1229static inline u32 gmmu_pte_kind_c128_ms2_2c_v(void)
1230{
1231 return 0x000000f6;
1232}
1233static inline u32 gmmu_pte_kind_c128_ms2_2cr_v(void)
1234{
1235 return 0x000000f7;
1236}
1237static inline u32 gmmu_pte_kind_c128_ms4_2c_v(void)
1238{
1239 return 0x000000f8;
1240}
1241static inline u32 gmmu_pte_kind_c128_ms4_2cr_v(void)
1242{
1243 return 0x000000f9;
1244}
1245static inline u32 gmmu_pte_kind_c128_ms8_ms16_2c_v(void)
1246{
1247 return 0x000000fa;
1248}
1249static inline u32 gmmu_pte_kind_c128_ms8_ms16_2cr_v(void)
1250{
1251 return 0x000000fb;
1252}
1253static inline u32 gmmu_pte_kind_x8c24_v(void)
1254{
1255 return 0x000000fc;
1256}
1257static inline u32 gmmu_pte_kind_pitch_no_swizzle_v(void)
1258{
1259 return 0x000000fd;
1260}
1261static inline u32 gmmu_pte_kind_smsked_message_v(void)
1262{
1263 return 0x000000ca;
1264}
1265static inline u32 gmmu_pte_kind_smhost_message_v(void)
1266{
1267 return 0x000000cb;
1268}
1269static inline u32 gmmu_pte_kind_s8_v(void)
1270{
1271 return 0x0000002a;
1272}
1273static inline u32 gmmu_pte_kind_s8_2s_v(void)
1274{
1275 return 0x0000002b;
1276}
1277#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_gr_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_gr_gp10b.h
new file mode 100644
index 00000000..9e3137e7
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_gr_gp10b.h
@@ -0,0 +1,4241 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_gr_gp10b_h_
51#define _hw_gr_gp10b_h_
52
53static inline u32 gr_intr_r(void)
54{
55 return 0x00400100;
56}
57static inline u32 gr_intr_notify_pending_f(void)
58{
59 return 0x1;
60}
61static inline u32 gr_intr_notify_reset_f(void)
62{
63 return 0x1;
64}
65static inline u32 gr_intr_semaphore_pending_f(void)
66{
67 return 0x2;
68}
69static inline u32 gr_intr_semaphore_reset_f(void)
70{
71 return 0x2;
72}
73static inline u32 gr_intr_illegal_method_pending_f(void)
74{
75 return 0x10;
76}
77static inline u32 gr_intr_illegal_method_reset_f(void)
78{
79 return 0x10;
80}
81static inline u32 gr_intr_illegal_notify_pending_f(void)
82{
83 return 0x40;
84}
85static inline u32 gr_intr_illegal_notify_reset_f(void)
86{
87 return 0x40;
88}
89static inline u32 gr_intr_firmware_method_f(u32 v)
90{
91 return (v & 0x1) << 8;
92}
93static inline u32 gr_intr_firmware_method_pending_f(void)
94{
95 return 0x100;
96}
97static inline u32 gr_intr_firmware_method_reset_f(void)
98{
99 return 0x100;
100}
101static inline u32 gr_intr_illegal_class_pending_f(void)
102{
103 return 0x20;
104}
105static inline u32 gr_intr_illegal_class_reset_f(void)
106{
107 return 0x20;
108}
109static inline u32 gr_intr_fecs_error_pending_f(void)
110{
111 return 0x80000;
112}
113static inline u32 gr_intr_fecs_error_reset_f(void)
114{
115 return 0x80000;
116}
117static inline u32 gr_intr_class_error_pending_f(void)
118{
119 return 0x100000;
120}
121static inline u32 gr_intr_class_error_reset_f(void)
122{
123 return 0x100000;
124}
125static inline u32 gr_intr_exception_pending_f(void)
126{
127 return 0x200000;
128}
129static inline u32 gr_intr_exception_reset_f(void)
130{
131 return 0x200000;
132}
133static inline u32 gr_fecs_intr_r(void)
134{
135 return 0x00400144;
136}
137static inline u32 gr_class_error_r(void)
138{
139 return 0x00400110;
140}
141static inline u32 gr_class_error_code_v(u32 r)
142{
143 return (r >> 0) & 0xffff;
144}
145static inline u32 gr_intr_nonstall_r(void)
146{
147 return 0x00400120;
148}
149static inline u32 gr_intr_nonstall_trap_pending_f(void)
150{
151 return 0x2;
152}
153static inline u32 gr_intr_en_r(void)
154{
155 return 0x0040013c;
156}
157static inline u32 gr_exception_r(void)
158{
159 return 0x00400108;
160}
161static inline u32 gr_exception_fe_m(void)
162{
163 return 0x1 << 0;
164}
165static inline u32 gr_exception_gpc_m(void)
166{
167 return 0x1 << 24;
168}
169static inline u32 gr_exception_memfmt_m(void)
170{
171 return 0x1 << 1;
172}
173static inline u32 gr_exception_ds_m(void)
174{
175 return 0x1 << 4;
176}
177static inline u32 gr_exception1_r(void)
178{
179 return 0x00400118;
180}
181static inline u32 gr_exception1_gpc_0_pending_f(void)
182{
183 return 0x1;
184}
185static inline u32 gr_exception2_r(void)
186{
187 return 0x0040011c;
188}
189static inline u32 gr_exception_en_r(void)
190{
191 return 0x00400138;
192}
193static inline u32 gr_exception_en_fe_m(void)
194{
195 return 0x1 << 0;
196}
197static inline u32 gr_exception1_en_r(void)
198{
199 return 0x00400130;
200}
201static inline u32 gr_exception2_en_r(void)
202{
203 return 0x00400134;
204}
205static inline u32 gr_gpfifo_ctl_r(void)
206{
207 return 0x00400500;
208}
209static inline u32 gr_gpfifo_ctl_access_f(u32 v)
210{
211 return (v & 0x1) << 0;
212}
213static inline u32 gr_gpfifo_ctl_access_disabled_f(void)
214{
215 return 0x0;
216}
217static inline u32 gr_gpfifo_ctl_access_enabled_f(void)
218{
219 return 0x1;
220}
221static inline u32 gr_gpfifo_ctl_semaphore_access_f(u32 v)
222{
223 return (v & 0x1) << 16;
224}
225static inline u32 gr_gpfifo_ctl_semaphore_access_enabled_v(void)
226{
227 return 0x00000001;
228}
229static inline u32 gr_gpfifo_ctl_semaphore_access_enabled_f(void)
230{
231 return 0x10000;
232}
233static inline u32 gr_gpfifo_status_r(void)
234{
235 return 0x00400504;
236}
237static inline u32 gr_trapped_addr_r(void)
238{
239 return 0x00400704;
240}
241static inline u32 gr_trapped_addr_mthd_v(u32 r)
242{
243 return (r >> 2) & 0xfff;
244}
245static inline u32 gr_trapped_addr_subch_v(u32 r)
246{
247 return (r >> 16) & 0x7;
248}
249static inline u32 gr_trapped_data_lo_r(void)
250{
251 return 0x00400708;
252}
253static inline u32 gr_trapped_data_hi_r(void)
254{
255 return 0x0040070c;
256}
257static inline u32 gr_status_r(void)
258{
259 return 0x00400700;
260}
261static inline u32 gr_status_fe_method_upper_v(u32 r)
262{
263 return (r >> 1) & 0x1;
264}
265static inline u32 gr_status_fe_method_lower_v(u32 r)
266{
267 return (r >> 2) & 0x1;
268}
269static inline u32 gr_status_fe_method_lower_idle_v(void)
270{
271 return 0x00000000;
272}
273static inline u32 gr_status_fe_gi_v(u32 r)
274{
275 return (r >> 21) & 0x1;
276}
277static inline u32 gr_status_mask_r(void)
278{
279 return 0x00400610;
280}
281static inline u32 gr_status_1_r(void)
282{
283 return 0x00400604;
284}
285static inline u32 gr_status_2_r(void)
286{
287 return 0x00400608;
288}
289static inline u32 gr_engine_status_r(void)
290{
291 return 0x0040060c;
292}
293static inline u32 gr_engine_status_value_busy_f(void)
294{
295 return 0x1;
296}
297static inline u32 gr_pri_be0_becs_be_exception_r(void)
298{
299 return 0x00410204;
300}
301static inline u32 gr_pri_be0_becs_be_exception_en_r(void)
302{
303 return 0x00410208;
304}
305static inline u32 gr_pri_gpc0_gpccs_gpc_exception_r(void)
306{
307 return 0x00502c90;
308}
309static inline u32 gr_pri_gpc0_gpccs_gpc_exception_en_r(void)
310{
311 return 0x00502c94;
312}
313static inline u32 gr_pri_gpc0_tpc0_tpccs_tpc_exception_r(void)
314{
315 return 0x00504508;
316}
317static inline u32 gr_pri_gpc0_tpc0_tpccs_tpc_exception_en_r(void)
318{
319 return 0x0050450c;
320}
321static inline u32 gr_activity_0_r(void)
322{
323 return 0x00400380;
324}
325static inline u32 gr_activity_1_r(void)
326{
327 return 0x00400384;
328}
329static inline u32 gr_activity_2_r(void)
330{
331 return 0x00400388;
332}
333static inline u32 gr_activity_4_r(void)
334{
335 return 0x00400390;
336}
337static inline u32 gr_activity_4_gpc0_s(void)
338{
339 return 3;
340}
341static inline u32 gr_activity_4_gpc0_f(u32 v)
342{
343 return (v & 0x7) << 0;
344}
345static inline u32 gr_activity_4_gpc0_m(void)
346{
347 return 0x7 << 0;
348}
349static inline u32 gr_activity_4_gpc0_v(u32 r)
350{
351 return (r >> 0) & 0x7;
352}
353static inline u32 gr_activity_4_gpc0_empty_v(void)
354{
355 return 0x00000000;
356}
357static inline u32 gr_activity_4_gpc0_preempted_v(void)
358{
359 return 0x00000004;
360}
361static inline u32 gr_pri_gpc0_gcc_dbg_r(void)
362{
363 return 0x00501000;
364}
365static inline u32 gr_pri_gpcs_gcc_dbg_r(void)
366{
367 return 0x00419000;
368}
369static inline u32 gr_pri_gpcs_gcc_dbg_invalidate_m(void)
370{
371 return 0x1 << 1;
372}
373static inline u32 gr_pri_gpc0_tpc0_sm_cache_control_r(void)
374{
375 return 0x005046a4;
376}
377static inline u32 gr_pri_gpcs_tpcs_sm_cache_control_r(void)
378{
379 return 0x00419ea4;
380}
381static inline u32 gr_pri_gpcs_tpcs_sm_cache_control_invalidate_cache_m(void)
382{
383 return 0x1 << 0;
384}
385static inline u32 gr_pri_sked_activity_r(void)
386{
387 return 0x00407054;
388}
389static inline u32 gr_pri_gpc0_gpccs_gpc_activity0_r(void)
390{
391 return 0x00502c80;
392}
393static inline u32 gr_pri_gpc0_gpccs_gpc_activity1_r(void)
394{
395 return 0x00502c84;
396}
397static inline u32 gr_pri_gpc0_gpccs_gpc_activity2_r(void)
398{
399 return 0x00502c88;
400}
401static inline u32 gr_pri_gpc0_gpccs_gpc_activity3_r(void)
402{
403 return 0x00502c8c;
404}
405static inline u32 gr_pri_gpc0_tpc0_tpccs_tpc_activity_0_r(void)
406{
407 return 0x00504500;
408}
409static inline u32 gr_pri_gpc0_tpc1_tpccs_tpc_activity_0_r(void)
410{
411 return 0x00504d00;
412}
413static inline u32 gr_pri_gpc0_tpcs_tpccs_tpc_activity_0_r(void)
414{
415 return 0x00501d00;
416}
417static inline u32 gr_pri_gpcs_gpccs_gpc_activity_0_r(void)
418{
419 return 0x0041ac80;
420}
421static inline u32 gr_pri_gpcs_gpccs_gpc_activity_1_r(void)
422{
423 return 0x0041ac84;
424}
425static inline u32 gr_pri_gpcs_gpccs_gpc_activity_2_r(void)
426{
427 return 0x0041ac88;
428}
429static inline u32 gr_pri_gpcs_gpccs_gpc_activity_3_r(void)
430{
431 return 0x0041ac8c;
432}
433static inline u32 gr_pri_gpcs_tpc0_tpccs_tpc_activity_0_r(void)
434{
435 return 0x0041c500;
436}
437static inline u32 gr_pri_gpcs_tpc1_tpccs_tpc_activity_0_r(void)
438{
439 return 0x0041cd00;
440}
441static inline u32 gr_pri_gpcs_tpcs_tpccs_tpc_activity_0_r(void)
442{
443 return 0x00419d00;
444}
445static inline u32 gr_pri_be0_becs_be_activity0_r(void)
446{
447 return 0x00410200;
448}
449static inline u32 gr_pri_be1_becs_be_activity0_r(void)
450{
451 return 0x00410600;
452}
453static inline u32 gr_pri_bes_becs_be_activity0_r(void)
454{
455 return 0x00408a00;
456}
457static inline u32 gr_pri_ds_mpipe_status_r(void)
458{
459 return 0x00405858;
460}
461static inline u32 gr_pri_fe_go_idle_info_r(void)
462{
463 return 0x00404194;
464}
465static inline u32 gr_pri_gpc0_tpc0_tex_m_tex_subunits_status_r(void)
466{
467 return 0x00504238;
468}
469static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_r(void)
470{
471 return 0x005046b8;
472}
473static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp0_b(void)
474{
475 return 4;
476}
477static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp0_pending_f(void)
478{
479 return 0x10;
480}
481static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp1_pending_f(void)
482{
483 return 0x20;
484}
485static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp2_pending_f(void)
486{
487 return 0x40;
488}
489static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_single_err_detected_qrfdp3_pending_f(void)
490{
491 return 0x80;
492}
493static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp0_b(void)
494{
495 return 8;
496}
497static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp0_pending_f(void)
498{
499 return 0x100;
500}
501static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp1_pending_f(void)
502{
503 return 0x200;
504}
505static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp2_pending_f(void)
506{
507 return 0x400;
508}
509static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_status_double_err_detected_qrfdp3_pending_f(void)
510{
511 return 0x800;
512}
513static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_r(void)
514{
515 return 0x005044a0;
516}
517static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_corrected_shm0_pending_f(void)
518{
519 return 0x1;
520}
521static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_corrected_shm1_pending_f(void)
522{
523 return 0x2;
524}
525static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_detected_shm0_pending_f(void)
526{
527 return 0x10;
528}
529static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_single_err_detected_shm1_pending_f(void)
530{
531 return 0x20;
532}
533static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_double_err_detected_shm0_pending_f(void)
534{
535 return 0x100;
536}
537static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_status_double_err_detected_shm1_pending_f(void)
538{
539 return 0x200;
540}
541static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_single_err_count_r(void)
542{
543 return 0x005046bc;
544}
545static inline u32 gr_pri_gpc0_tpc0_sm_lrf_ecc_double_err_count_r(void)
546{
547 return 0x005046c0;
548}
549static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_r(void)
550{
551 return 0x005044a4;
552}
553static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_corrected_m(void)
554{
555 return 0xff << 0;
556}
557static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_corrected_v(u32 r)
558{
559 return (r >> 0) & 0xff;
560}
561static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_detected_m(void)
562{
563 return 0xff << 8;
564}
565static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_single_detected_v(u32 r)
566{
567 return (r >> 8) & 0xff;
568}
569static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_double_detected_m(void)
570{
571 return 0xff << 16;
572}
573static inline u32 gr_pri_gpc0_tpc0_sm_shm_ecc_err_count_double_detected_v(u32 r)
574{
575 return (r >> 16) & 0xff;
576}
577static inline u32 gr_pri_gpc0_tpc0_tex_m_routing_r(void)
578{
579 return 0x005042c4;
580}
581static inline u32 gr_pri_gpc0_tpc0_tex_m_routing_sel_default_f(void)
582{
583 return 0x0;
584}
585static inline u32 gr_pri_gpc0_tpc0_tex_m_routing_sel_pipe0_f(void)
586{
587 return 0x1;
588}
589static inline u32 gr_pri_gpc0_tpc0_tex_m_routing_sel_pipe1_f(void)
590{
591 return 0x2;
592}
593static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_r(void)
594{
595 return 0x00504218;
596}
597static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_sec_m(void)
598{
599 return 0xffff << 0;
600}
601static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_sec_v(u32 r)
602{
603 return (r >> 0) & 0xffff;
604}
605static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_ded_m(void)
606{
607 return 0xffff << 16;
608}
609static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_total_ded_v(u32 r)
610{
611 return (r >> 16) & 0xffff;
612}
613static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_r(void)
614{
615 return 0x005042ec;
616}
617static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_sec_m(void)
618{
619 return 0xffff << 0;
620}
621static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_sec_v(u32 r)
622{
623 return (r >> 0) & 0xffff;
624}
625static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_ded_m(void)
626{
627 return 0xffff << 16;
628}
629static inline u32 gr_pri_gpc0_tpc0_tex_m_ecc_cnt_unique_ded_v(u32 r)
630{
631 return (r >> 16) & 0xffff;
632}
633static inline u32 gr_pri_be0_crop_status1_r(void)
634{
635 return 0x00410134;
636}
637static inline u32 gr_pri_bes_crop_status1_r(void)
638{
639 return 0x00408934;
640}
641static inline u32 gr_pri_be0_zrop_status_r(void)
642{
643 return 0x00410048;
644}
645static inline u32 gr_pri_be0_zrop_status2_r(void)
646{
647 return 0x0041004c;
648}
649static inline u32 gr_pri_bes_zrop_status_r(void)
650{
651 return 0x00408848;
652}
653static inline u32 gr_pri_bes_zrop_status2_r(void)
654{
655 return 0x0040884c;
656}
657static inline u32 gr_pipe_bundle_address_r(void)
658{
659 return 0x00400200;
660}
661static inline u32 gr_pipe_bundle_address_value_v(u32 r)
662{
663 return (r >> 0) & 0xffff;
664}
665static inline u32 gr_pipe_bundle_data_r(void)
666{
667 return 0x00400204;
668}
669static inline u32 gr_pipe_bundle_config_r(void)
670{
671 return 0x00400208;
672}
673static inline u32 gr_pipe_bundle_config_override_pipe_mode_disabled_f(void)
674{
675 return 0x0;
676}
677static inline u32 gr_pipe_bundle_config_override_pipe_mode_enabled_f(void)
678{
679 return 0x80000000;
680}
681static inline u32 gr_fe_hww_esr_r(void)
682{
683 return 0x00404000;
684}
685static inline u32 gr_fe_hww_esr_reset_active_f(void)
686{
687 return 0x40000000;
688}
689static inline u32 gr_fe_hww_esr_en_enable_f(void)
690{
691 return 0x80000000;
692}
693static inline u32 gr_fe_go_idle_timeout_r(void)
694{
695 return 0x00404154;
696}
697static inline u32 gr_fe_go_idle_timeout_count_f(u32 v)
698{
699 return (v & 0xffffffff) << 0;
700}
701static inline u32 gr_fe_go_idle_timeout_count_disabled_f(void)
702{
703 return 0x0;
704}
705static inline u32 gr_fe_go_idle_timeout_count_prod_f(void)
706{
707 return 0x7fffffff;
708}
709static inline u32 gr_fe_object_table_r(u32 i)
710{
711 return 0x00404200 + i*4;
712}
713static inline u32 gr_fe_object_table_nvclass_v(u32 r)
714{
715 return (r >> 0) & 0xffff;
716}
717static inline u32 gr_fe_tpc_fs_r(void)
718{
719 return 0x004041c4;
720}
721static inline u32 gr_pri_mme_shadow_raw_index_r(void)
722{
723 return 0x00404488;
724}
725static inline u32 gr_pri_mme_shadow_raw_index_write_trigger_f(void)
726{
727 return 0x80000000;
728}
729static inline u32 gr_pri_mme_shadow_raw_data_r(void)
730{
731 return 0x0040448c;
732}
733static inline u32 gr_mme_hww_esr_r(void)
734{
735 return 0x00404490;
736}
737static inline u32 gr_mme_hww_esr_reset_active_f(void)
738{
739 return 0x40000000;
740}
741static inline u32 gr_mme_hww_esr_en_enable_f(void)
742{
743 return 0x80000000;
744}
745static inline u32 gr_memfmt_hww_esr_r(void)
746{
747 return 0x00404600;
748}
749static inline u32 gr_memfmt_hww_esr_reset_active_f(void)
750{
751 return 0x40000000;
752}
753static inline u32 gr_memfmt_hww_esr_en_enable_f(void)
754{
755 return 0x80000000;
756}
757static inline u32 gr_fecs_cpuctl_r(void)
758{
759 return 0x00409100;
760}
761static inline u32 gr_fecs_cpuctl_startcpu_f(u32 v)
762{
763 return (v & 0x1) << 1;
764}
765static inline u32 gr_fecs_cpuctl_alias_r(void)
766{
767 return 0x00409130;
768}
769static inline u32 gr_fecs_cpuctl_alias_startcpu_f(u32 v)
770{
771 return (v & 0x1) << 1;
772}
773static inline u32 gr_fecs_dmactl_r(void)
774{
775 return 0x0040910c;
776}
777static inline u32 gr_fecs_dmactl_require_ctx_f(u32 v)
778{
779 return (v & 0x1) << 0;
780}
781static inline u32 gr_fecs_dmactl_dmem_scrubbing_m(void)
782{
783 return 0x1 << 1;
784}
785static inline u32 gr_fecs_dmactl_imem_scrubbing_m(void)
786{
787 return 0x1 << 2;
788}
789static inline u32 gr_fecs_os_r(void)
790{
791 return 0x00409080;
792}
793static inline u32 gr_fecs_idlestate_r(void)
794{
795 return 0x0040904c;
796}
797static inline u32 gr_fecs_mailbox0_r(void)
798{
799 return 0x00409040;
800}
801static inline u32 gr_fecs_mailbox1_r(void)
802{
803 return 0x00409044;
804}
805static inline u32 gr_fecs_irqstat_r(void)
806{
807 return 0x00409008;
808}
809static inline u32 gr_fecs_irqmode_r(void)
810{
811 return 0x0040900c;
812}
813static inline u32 gr_fecs_irqmask_r(void)
814{
815 return 0x00409018;
816}
817static inline u32 gr_fecs_irqdest_r(void)
818{
819 return 0x0040901c;
820}
821static inline u32 gr_fecs_curctx_r(void)
822{
823 return 0x00409050;
824}
825static inline u32 gr_fecs_nxtctx_r(void)
826{
827 return 0x00409054;
828}
829static inline u32 gr_fecs_engctl_r(void)
830{
831 return 0x004090a4;
832}
833static inline u32 gr_fecs_debug1_r(void)
834{
835 return 0x00409090;
836}
837static inline u32 gr_fecs_debuginfo_r(void)
838{
839 return 0x00409094;
840}
841static inline u32 gr_fecs_icd_cmd_r(void)
842{
843 return 0x00409200;
844}
845static inline u32 gr_fecs_icd_cmd_opc_s(void)
846{
847 return 4;
848}
849static inline u32 gr_fecs_icd_cmd_opc_f(u32 v)
850{
851 return (v & 0xf) << 0;
852}
853static inline u32 gr_fecs_icd_cmd_opc_m(void)
854{
855 return 0xf << 0;
856}
857static inline u32 gr_fecs_icd_cmd_opc_v(u32 r)
858{
859 return (r >> 0) & 0xf;
860}
861static inline u32 gr_fecs_icd_cmd_opc_rreg_f(void)
862{
863 return 0x8;
864}
865static inline u32 gr_fecs_icd_cmd_opc_rstat_f(void)
866{
867 return 0xe;
868}
869static inline u32 gr_fecs_icd_cmd_idx_f(u32 v)
870{
871 return (v & 0x1f) << 8;
872}
873static inline u32 gr_fecs_icd_rdata_r(void)
874{
875 return 0x0040920c;
876}
877static inline u32 gr_fecs_imemc_r(u32 i)
878{
879 return 0x00409180 + i*16;
880}
881static inline u32 gr_fecs_imemc_offs_f(u32 v)
882{
883 return (v & 0x3f) << 2;
884}
885static inline u32 gr_fecs_imemc_blk_f(u32 v)
886{
887 return (v & 0xff) << 8;
888}
889static inline u32 gr_fecs_imemc_aincw_f(u32 v)
890{
891 return (v & 0x1) << 24;
892}
893static inline u32 gr_fecs_imemd_r(u32 i)
894{
895 return 0x00409184 + i*16;
896}
897static inline u32 gr_fecs_imemt_r(u32 i)
898{
899 return 0x00409188 + i*16;
900}
901static inline u32 gr_fecs_imemt_tag_f(u32 v)
902{
903 return (v & 0xffff) << 0;
904}
905static inline u32 gr_fecs_dmemc_r(u32 i)
906{
907 return 0x004091c0 + i*8;
908}
909static inline u32 gr_fecs_dmemc_offs_s(void)
910{
911 return 6;
912}
913static inline u32 gr_fecs_dmemc_offs_f(u32 v)
914{
915 return (v & 0x3f) << 2;
916}
917static inline u32 gr_fecs_dmemc_offs_m(void)
918{
919 return 0x3f << 2;
920}
921static inline u32 gr_fecs_dmemc_offs_v(u32 r)
922{
923 return (r >> 2) & 0x3f;
924}
925static inline u32 gr_fecs_dmemc_blk_f(u32 v)
926{
927 return (v & 0xff) << 8;
928}
929static inline u32 gr_fecs_dmemc_aincw_f(u32 v)
930{
931 return (v & 0x1) << 24;
932}
933static inline u32 gr_fecs_dmemd_r(u32 i)
934{
935 return 0x004091c4 + i*8;
936}
937static inline u32 gr_fecs_dmatrfbase_r(void)
938{
939 return 0x00409110;
940}
941static inline u32 gr_fecs_dmatrfmoffs_r(void)
942{
943 return 0x00409114;
944}
945static inline u32 gr_fecs_dmatrffboffs_r(void)
946{
947 return 0x0040911c;
948}
949static inline u32 gr_fecs_dmatrfcmd_r(void)
950{
951 return 0x00409118;
952}
953static inline u32 gr_fecs_dmatrfcmd_imem_f(u32 v)
954{
955 return (v & 0x1) << 4;
956}
957static inline u32 gr_fecs_dmatrfcmd_write_f(u32 v)
958{
959 return (v & 0x1) << 5;
960}
961static inline u32 gr_fecs_dmatrfcmd_size_f(u32 v)
962{
963 return (v & 0x7) << 8;
964}
965static inline u32 gr_fecs_dmatrfcmd_ctxdma_f(u32 v)
966{
967 return (v & 0x7) << 12;
968}
969static inline u32 gr_fecs_bootvec_r(void)
970{
971 return 0x00409104;
972}
973static inline u32 gr_fecs_bootvec_vec_f(u32 v)
974{
975 return (v & 0xffffffff) << 0;
976}
977static inline u32 gr_fecs_falcon_hwcfg_r(void)
978{
979 return 0x00409108;
980}
981static inline u32 gr_gpcs_gpccs_falcon_hwcfg_r(void)
982{
983 return 0x0041a108;
984}
985static inline u32 gr_fecs_falcon_rm_r(void)
986{
987 return 0x00409084;
988}
989static inline u32 gr_fecs_current_ctx_r(void)
990{
991 return 0x00409b00;
992}
993static inline u32 gr_fecs_current_ctx_ptr_f(u32 v)
994{
995 return (v & 0xfffffff) << 0;
996}
997static inline u32 gr_fecs_current_ctx_ptr_v(u32 r)
998{
999 return (r >> 0) & 0xfffffff;
1000}
1001static inline u32 gr_fecs_current_ctx_target_s(void)
1002{
1003 return 2;
1004}
1005static inline u32 gr_fecs_current_ctx_target_f(u32 v)
1006{
1007 return (v & 0x3) << 28;
1008}
1009static inline u32 gr_fecs_current_ctx_target_m(void)
1010{
1011 return 0x3 << 28;
1012}
1013static inline u32 gr_fecs_current_ctx_target_v(u32 r)
1014{
1015 return (r >> 28) & 0x3;
1016}
1017static inline u32 gr_fecs_current_ctx_target_vid_mem_f(void)
1018{
1019 return 0x0;
1020}
1021static inline u32 gr_fecs_current_ctx_target_sys_mem_coh_f(void)
1022{
1023 return 0x20000000;
1024}
1025static inline u32 gr_fecs_current_ctx_target_sys_mem_ncoh_f(void)
1026{
1027 return 0x30000000;
1028}
1029static inline u32 gr_fecs_current_ctx_valid_s(void)
1030{
1031 return 1;
1032}
1033static inline u32 gr_fecs_current_ctx_valid_f(u32 v)
1034{
1035 return (v & 0x1) << 31;
1036}
1037static inline u32 gr_fecs_current_ctx_valid_m(void)
1038{
1039 return 0x1 << 31;
1040}
1041static inline u32 gr_fecs_current_ctx_valid_v(u32 r)
1042{
1043 return (r >> 31) & 0x1;
1044}
1045static inline u32 gr_fecs_current_ctx_valid_false_f(void)
1046{
1047 return 0x0;
1048}
1049static inline u32 gr_fecs_method_data_r(void)
1050{
1051 return 0x00409500;
1052}
1053static inline u32 gr_fecs_method_push_r(void)
1054{
1055 return 0x00409504;
1056}
1057static inline u32 gr_fecs_method_push_adr_f(u32 v)
1058{
1059 return (v & 0xfff) << 0;
1060}
1061static inline u32 gr_fecs_method_push_adr_bind_pointer_v(void)
1062{
1063 return 0x00000003;
1064}
1065static inline u32 gr_fecs_method_push_adr_bind_pointer_f(void)
1066{
1067 return 0x3;
1068}
1069static inline u32 gr_fecs_method_push_adr_discover_image_size_v(void)
1070{
1071 return 0x00000010;
1072}
1073static inline u32 gr_fecs_method_push_adr_wfi_golden_save_v(void)
1074{
1075 return 0x00000009;
1076}
1077static inline u32 gr_fecs_method_push_adr_restore_golden_v(void)
1078{
1079 return 0x00000015;
1080}
1081static inline u32 gr_fecs_method_push_adr_discover_zcull_image_size_v(void)
1082{
1083 return 0x00000016;
1084}
1085static inline u32 gr_fecs_method_push_adr_discover_pm_image_size_v(void)
1086{
1087 return 0x00000025;
1088}
1089static inline u32 gr_fecs_method_push_adr_discover_reglist_image_size_v(void)
1090{
1091 return 0x00000030;
1092}
1093static inline u32 gr_fecs_method_push_adr_set_reglist_bind_instance_v(void)
1094{
1095 return 0x00000031;
1096}
1097static inline u32 gr_fecs_method_push_adr_set_reglist_virtual_address_v(void)
1098{
1099 return 0x00000032;
1100}
1101static inline u32 gr_fecs_method_push_adr_stop_ctxsw_v(void)
1102{
1103 return 0x00000038;
1104}
1105static inline u32 gr_fecs_method_push_adr_start_ctxsw_v(void)
1106{
1107 return 0x00000039;
1108}
1109static inline u32 gr_fecs_method_push_adr_set_watchdog_timeout_f(void)
1110{
1111 return 0x21;
1112}
1113static inline u32 gr_fecs_method_push_adr_write_timestamp_record_v(void)
1114{
1115 return 0x0000003d;
1116}
1117static inline u32 gr_fecs_method_push_adr_discover_preemption_image_size_v(void)
1118{
1119 return 0x0000001a;
1120}
1121static inline u32 gr_fecs_method_push_adr_halt_pipeline_v(void)
1122{
1123 return 0x00000004;
1124}
1125static inline u32 gr_fecs_method_push_adr_configure_interrupt_completion_option_v(void)
1126{
1127 return 0x0000003a;
1128}
1129static inline u32 gr_fecs_host_int_status_r(void)
1130{
1131 return 0x00409c18;
1132}
1133static inline u32 gr_fecs_host_int_status_fault_during_ctxsw_f(u32 v)
1134{
1135 return (v & 0x1) << 16;
1136}
1137static inline u32 gr_fecs_host_int_status_umimp_firmware_method_f(u32 v)
1138{
1139 return (v & 0x1) << 17;
1140}
1141static inline u32 gr_fecs_host_int_status_umimp_illegal_method_f(u32 v)
1142{
1143 return (v & 0x1) << 18;
1144}
1145static inline u32 gr_fecs_host_int_status_ctxsw_intr_f(u32 v)
1146{
1147 return (v & 0xffff) << 0;
1148}
1149static inline u32 gr_fecs_host_int_clear_r(void)
1150{
1151 return 0x00409c20;
1152}
1153static inline u32 gr_fecs_host_int_clear_ctxsw_intr1_f(u32 v)
1154{
1155 return (v & 0x1) << 1;
1156}
1157static inline u32 gr_fecs_host_int_clear_ctxsw_intr1_clear_f(void)
1158{
1159 return 0x2;
1160}
1161static inline u32 gr_fecs_host_int_enable_r(void)
1162{
1163 return 0x00409c24;
1164}
1165static inline u32 gr_fecs_host_int_enable_ctxsw_intr1_enable_f(void)
1166{
1167 return 0x2;
1168}
1169static inline u32 gr_fecs_host_int_enable_fault_during_ctxsw_enable_f(void)
1170{
1171 return 0x10000;
1172}
1173static inline u32 gr_fecs_host_int_enable_umimp_firmware_method_enable_f(void)
1174{
1175 return 0x20000;
1176}
1177static inline u32 gr_fecs_host_int_enable_umimp_illegal_method_enable_f(void)
1178{
1179 return 0x40000;
1180}
1181static inline u32 gr_fecs_host_int_enable_watchdog_enable_f(void)
1182{
1183 return 0x80000;
1184}
1185static inline u32 gr_fecs_ctxsw_reset_ctl_r(void)
1186{
1187 return 0x00409614;
1188}
1189static inline u32 gr_fecs_ctxsw_reset_ctl_sys_halt_disabled_f(void)
1190{
1191 return 0x0;
1192}
1193static inline u32 gr_fecs_ctxsw_reset_ctl_gpc_halt_disabled_f(void)
1194{
1195 return 0x0;
1196}
1197static inline u32 gr_fecs_ctxsw_reset_ctl_be_halt_disabled_f(void)
1198{
1199 return 0x0;
1200}
1201static inline u32 gr_fecs_ctxsw_reset_ctl_sys_engine_reset_disabled_f(void)
1202{
1203 return 0x10;
1204}
1205static inline u32 gr_fecs_ctxsw_reset_ctl_gpc_engine_reset_disabled_f(void)
1206{
1207 return 0x20;
1208}
1209static inline u32 gr_fecs_ctxsw_reset_ctl_be_engine_reset_disabled_f(void)
1210{
1211 return 0x40;
1212}
1213static inline u32 gr_fecs_ctxsw_reset_ctl_sys_context_reset_enabled_f(void)
1214{
1215 return 0x0;
1216}
1217static inline u32 gr_fecs_ctxsw_reset_ctl_sys_context_reset_disabled_f(void)
1218{
1219 return 0x100;
1220}
1221static inline u32 gr_fecs_ctxsw_reset_ctl_gpc_context_reset_enabled_f(void)
1222{
1223 return 0x0;
1224}
1225static inline u32 gr_fecs_ctxsw_reset_ctl_gpc_context_reset_disabled_f(void)
1226{
1227 return 0x200;
1228}
1229static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_s(void)
1230{
1231 return 1;
1232}
1233static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_f(u32 v)
1234{
1235 return (v & 0x1) << 10;
1236}
1237static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_m(void)
1238{
1239 return 0x1 << 10;
1240}
1241static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_v(u32 r)
1242{
1243 return (r >> 10) & 0x1;
1244}
1245static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_enabled_f(void)
1246{
1247 return 0x0;
1248}
1249static inline u32 gr_fecs_ctxsw_reset_ctl_be_context_reset_disabled_f(void)
1250{
1251 return 0x400;
1252}
1253static inline u32 gr_fecs_ctx_state_store_major_rev_id_r(void)
1254{
1255 return 0x0040960c;
1256}
1257static inline u32 gr_fecs_ctxsw_mailbox_r(u32 i)
1258{
1259 return 0x00409800 + i*4;
1260}
1261static inline u32 gr_fecs_ctxsw_mailbox__size_1_v(void)
1262{
1263 return 0x00000010;
1264}
1265static inline u32 gr_fecs_ctxsw_mailbox_value_f(u32 v)
1266{
1267 return (v & 0xffffffff) << 0;
1268}
1269static inline u32 gr_fecs_ctxsw_mailbox_value_pass_v(void)
1270{
1271 return 0x00000001;
1272}
1273static inline u32 gr_fecs_ctxsw_mailbox_value_fail_v(void)
1274{
1275 return 0x00000002;
1276}
1277static inline u32 gr_fecs_ctxsw_mailbox_set_r(u32 i)
1278{
1279 return 0x004098c0 + i*4;
1280}
1281static inline u32 gr_fecs_ctxsw_mailbox_set_value_f(u32 v)
1282{
1283 return (v & 0xffffffff) << 0;
1284}
1285static inline u32 gr_fecs_ctxsw_mailbox_clear_r(u32 i)
1286{
1287 return 0x00409840 + i*4;
1288}
1289static inline u32 gr_fecs_ctxsw_mailbox_clear_value_f(u32 v)
1290{
1291 return (v & 0xffffffff) << 0;
1292}
1293static inline u32 gr_fecs_fs_r(void)
1294{
1295 return 0x00409604;
1296}
1297static inline u32 gr_fecs_fs_num_available_gpcs_s(void)
1298{
1299 return 5;
1300}
1301static inline u32 gr_fecs_fs_num_available_gpcs_f(u32 v)
1302{
1303 return (v & 0x1f) << 0;
1304}
1305static inline u32 gr_fecs_fs_num_available_gpcs_m(void)
1306{
1307 return 0x1f << 0;
1308}
1309static inline u32 gr_fecs_fs_num_available_gpcs_v(u32 r)
1310{
1311 return (r >> 0) & 0x1f;
1312}
1313static inline u32 gr_fecs_fs_num_available_fbps_s(void)
1314{
1315 return 5;
1316}
1317static inline u32 gr_fecs_fs_num_available_fbps_f(u32 v)
1318{
1319 return (v & 0x1f) << 16;
1320}
1321static inline u32 gr_fecs_fs_num_available_fbps_m(void)
1322{
1323 return 0x1f << 16;
1324}
1325static inline u32 gr_fecs_fs_num_available_fbps_v(u32 r)
1326{
1327 return (r >> 16) & 0x1f;
1328}
1329static inline u32 gr_fecs_cfg_r(void)
1330{
1331 return 0x00409620;
1332}
1333static inline u32 gr_fecs_cfg_imem_sz_v(u32 r)
1334{
1335 return (r >> 0) & 0xff;
1336}
1337static inline u32 gr_fecs_rc_lanes_r(void)
1338{
1339 return 0x00409880;
1340}
1341static inline u32 gr_fecs_rc_lanes_num_chains_s(void)
1342{
1343 return 6;
1344}
1345static inline u32 gr_fecs_rc_lanes_num_chains_f(u32 v)
1346{
1347 return (v & 0x3f) << 0;
1348}
1349static inline u32 gr_fecs_rc_lanes_num_chains_m(void)
1350{
1351 return 0x3f << 0;
1352}
1353static inline u32 gr_fecs_rc_lanes_num_chains_v(u32 r)
1354{
1355 return (r >> 0) & 0x3f;
1356}
1357static inline u32 gr_fecs_ctxsw_status_1_r(void)
1358{
1359 return 0x00409400;
1360}
1361static inline u32 gr_fecs_ctxsw_status_1_arb_busy_s(void)
1362{
1363 return 1;
1364}
1365static inline u32 gr_fecs_ctxsw_status_1_arb_busy_f(u32 v)
1366{
1367 return (v & 0x1) << 12;
1368}
1369static inline u32 gr_fecs_ctxsw_status_1_arb_busy_m(void)
1370{
1371 return 0x1 << 12;
1372}
1373static inline u32 gr_fecs_ctxsw_status_1_arb_busy_v(u32 r)
1374{
1375 return (r >> 12) & 0x1;
1376}
1377static inline u32 gr_fecs_arb_ctx_adr_r(void)
1378{
1379 return 0x00409a24;
1380}
1381static inline u32 gr_fecs_new_ctx_r(void)
1382{
1383 return 0x00409b04;
1384}
1385static inline u32 gr_fecs_new_ctx_ptr_s(void)
1386{
1387 return 28;
1388}
1389static inline u32 gr_fecs_new_ctx_ptr_f(u32 v)
1390{
1391 return (v & 0xfffffff) << 0;
1392}
1393static inline u32 gr_fecs_new_ctx_ptr_m(void)
1394{
1395 return 0xfffffff << 0;
1396}
1397static inline u32 gr_fecs_new_ctx_ptr_v(u32 r)
1398{
1399 return (r >> 0) & 0xfffffff;
1400}
1401static inline u32 gr_fecs_new_ctx_target_s(void)
1402{
1403 return 2;
1404}
1405static inline u32 gr_fecs_new_ctx_target_f(u32 v)
1406{
1407 return (v & 0x3) << 28;
1408}
1409static inline u32 gr_fecs_new_ctx_target_m(void)
1410{
1411 return 0x3 << 28;
1412}
1413static inline u32 gr_fecs_new_ctx_target_v(u32 r)
1414{
1415 return (r >> 28) & 0x3;
1416}
1417static inline u32 gr_fecs_new_ctx_target_vid_mem_f(void)
1418{
1419 return 0x0;
1420}
1421static inline u32 gr_fecs_new_ctx_target_sys_mem_ncoh_f(void)
1422{
1423 return 0x30000000;
1424}
1425static inline u32 gr_fecs_new_ctx_valid_s(void)
1426{
1427 return 1;
1428}
1429static inline u32 gr_fecs_new_ctx_valid_f(u32 v)
1430{
1431 return (v & 0x1) << 31;
1432}
1433static inline u32 gr_fecs_new_ctx_valid_m(void)
1434{
1435 return 0x1 << 31;
1436}
1437static inline u32 gr_fecs_new_ctx_valid_v(u32 r)
1438{
1439 return (r >> 31) & 0x1;
1440}
1441static inline u32 gr_fecs_arb_ctx_ptr_r(void)
1442{
1443 return 0x00409a0c;
1444}
1445static inline u32 gr_fecs_arb_ctx_ptr_ptr_s(void)
1446{
1447 return 28;
1448}
1449static inline u32 gr_fecs_arb_ctx_ptr_ptr_f(u32 v)
1450{
1451 return (v & 0xfffffff) << 0;
1452}
1453static inline u32 gr_fecs_arb_ctx_ptr_ptr_m(void)
1454{
1455 return 0xfffffff << 0;
1456}
1457static inline u32 gr_fecs_arb_ctx_ptr_ptr_v(u32 r)
1458{
1459 return (r >> 0) & 0xfffffff;
1460}
1461static inline u32 gr_fecs_arb_ctx_ptr_target_s(void)
1462{
1463 return 2;
1464}
1465static inline u32 gr_fecs_arb_ctx_ptr_target_f(u32 v)
1466{
1467 return (v & 0x3) << 28;
1468}
1469static inline u32 gr_fecs_arb_ctx_ptr_target_m(void)
1470{
1471 return 0x3 << 28;
1472}
1473static inline u32 gr_fecs_arb_ctx_ptr_target_v(u32 r)
1474{
1475 return (r >> 28) & 0x3;
1476}
1477static inline u32 gr_fecs_arb_ctx_ptr_target_vid_mem_f(void)
1478{
1479 return 0x0;
1480}
1481static inline u32 gr_fecs_arb_ctx_ptr_target_sys_mem_ncoh_f(void)
1482{
1483 return 0x30000000;
1484}
1485static inline u32 gr_fecs_arb_ctx_cmd_r(void)
1486{
1487 return 0x00409a10;
1488}
1489static inline u32 gr_fecs_arb_ctx_cmd_cmd_s(void)
1490{
1491 return 5;
1492}
1493static inline u32 gr_fecs_arb_ctx_cmd_cmd_f(u32 v)
1494{
1495 return (v & 0x1f) << 0;
1496}
1497static inline u32 gr_fecs_arb_ctx_cmd_cmd_m(void)
1498{
1499 return 0x1f << 0;
1500}
1501static inline u32 gr_fecs_arb_ctx_cmd_cmd_v(u32 r)
1502{
1503 return (r >> 0) & 0x1f;
1504}
1505static inline u32 gr_fecs_ctxsw_status_fe_0_r(void)
1506{
1507 return 0x00409c00;
1508}
1509static inline u32 gr_gpc0_gpccs_ctxsw_status_gpc_0_r(void)
1510{
1511 return 0x00502c04;
1512}
1513static inline u32 gr_gpc0_gpccs_ctxsw_status_1_r(void)
1514{
1515 return 0x00502400;
1516}
1517static inline u32 gr_fecs_ctxsw_idlestate_r(void)
1518{
1519 return 0x00409420;
1520}
1521static inline u32 gr_fecs_feature_override_ecc_r(void)
1522{
1523 return 0x00409658;
1524}
1525static inline u32 gr_fecs_feature_override_ecc_sm_lrf_override_v(u32 r)
1526{
1527 return (r >> 3) & 0x1;
1528}
1529static inline u32 gr_fecs_feature_override_ecc_sm_shm_override_v(u32 r)
1530{
1531 return (r >> 7) & 0x1;
1532}
1533static inline u32 gr_fecs_feature_override_ecc_tex_override_v(u32 r)
1534{
1535 return (r >> 11) & 0x1;
1536}
1537static inline u32 gr_fecs_feature_override_ecc_ltc_override_v(u32 r)
1538{
1539 return (r >> 15) & 0x1;
1540}
1541static inline u32 gr_fecs_feature_override_ecc_sm_lrf_v(u32 r)
1542{
1543 return (r >> 0) & 0x1;
1544}
1545static inline u32 gr_fecs_feature_override_ecc_sm_shm_v(u32 r)
1546{
1547 return (r >> 4) & 0x1;
1548}
1549static inline u32 gr_fecs_feature_override_ecc_tex_v(u32 r)
1550{
1551 return (r >> 8) & 0x1;
1552}
1553static inline u32 gr_fecs_feature_override_ecc_ltc_v(u32 r)
1554{
1555 return (r >> 12) & 0x1;
1556}
1557static inline u32 gr_gpc0_gpccs_ctxsw_idlestate_r(void)
1558{
1559 return 0x00502420;
1560}
1561static inline u32 gr_rstr2d_gpc_map0_r(void)
1562{
1563 return 0x0040780c;
1564}
1565static inline u32 gr_rstr2d_gpc_map1_r(void)
1566{
1567 return 0x00407810;
1568}
1569static inline u32 gr_rstr2d_gpc_map2_r(void)
1570{
1571 return 0x00407814;
1572}
1573static inline u32 gr_rstr2d_gpc_map3_r(void)
1574{
1575 return 0x00407818;
1576}
1577static inline u32 gr_rstr2d_gpc_map4_r(void)
1578{
1579 return 0x0040781c;
1580}
1581static inline u32 gr_rstr2d_gpc_map5_r(void)
1582{
1583 return 0x00407820;
1584}
1585static inline u32 gr_rstr2d_map_table_cfg_r(void)
1586{
1587 return 0x004078bc;
1588}
1589static inline u32 gr_rstr2d_map_table_cfg_row_offset_f(u32 v)
1590{
1591 return (v & 0xff) << 0;
1592}
1593static inline u32 gr_rstr2d_map_table_cfg_num_entries_f(u32 v)
1594{
1595 return (v & 0xff) << 8;
1596}
1597static inline u32 gr_pd_hww_esr_r(void)
1598{
1599 return 0x00406018;
1600}
1601static inline u32 gr_pd_hww_esr_reset_active_f(void)
1602{
1603 return 0x40000000;
1604}
1605static inline u32 gr_pd_hww_esr_en_enable_f(void)
1606{
1607 return 0x80000000;
1608}
1609static inline u32 gr_pd_num_tpc_per_gpc_r(u32 i)
1610{
1611 return 0x00406028 + i*4;
1612}
1613static inline u32 gr_pd_num_tpc_per_gpc__size_1_v(void)
1614{
1615 return 0x00000004;
1616}
1617static inline u32 gr_pd_num_tpc_per_gpc_count0_f(u32 v)
1618{
1619 return (v & 0xf) << 0;
1620}
1621static inline u32 gr_pd_num_tpc_per_gpc_count1_f(u32 v)
1622{
1623 return (v & 0xf) << 4;
1624}
1625static inline u32 gr_pd_num_tpc_per_gpc_count2_f(u32 v)
1626{
1627 return (v & 0xf) << 8;
1628}
1629static inline u32 gr_pd_num_tpc_per_gpc_count3_f(u32 v)
1630{
1631 return (v & 0xf) << 12;
1632}
1633static inline u32 gr_pd_num_tpc_per_gpc_count4_f(u32 v)
1634{
1635 return (v & 0xf) << 16;
1636}
1637static inline u32 gr_pd_num_tpc_per_gpc_count5_f(u32 v)
1638{
1639 return (v & 0xf) << 20;
1640}
1641static inline u32 gr_pd_num_tpc_per_gpc_count6_f(u32 v)
1642{
1643 return (v & 0xf) << 24;
1644}
1645static inline u32 gr_pd_num_tpc_per_gpc_count7_f(u32 v)
1646{
1647 return (v & 0xf) << 28;
1648}
1649static inline u32 gr_pd_ab_dist_cfg0_r(void)
1650{
1651 return 0x004064c0;
1652}
1653static inline u32 gr_pd_ab_dist_cfg0_timeslice_enable_en_f(void)
1654{
1655 return 0x80000000;
1656}
1657static inline u32 gr_pd_ab_dist_cfg0_timeslice_enable_dis_f(void)
1658{
1659 return 0x0;
1660}
1661static inline u32 gr_pd_ab_dist_cfg1_r(void)
1662{
1663 return 0x004064c4;
1664}
1665static inline u32 gr_pd_ab_dist_cfg1_max_batches_init_f(void)
1666{
1667 return 0xffff;
1668}
1669static inline u32 gr_pd_ab_dist_cfg1_max_output_f(u32 v)
1670{
1671 return (v & 0xffff) << 16;
1672}
1673static inline u32 gr_pd_ab_dist_cfg1_max_output_granularity_v(void)
1674{
1675 return 0x00000080;
1676}
1677static inline u32 gr_pd_ab_dist_cfg2_r(void)
1678{
1679 return 0x004064c8;
1680}
1681static inline u32 gr_pd_ab_dist_cfg2_token_limit_f(u32 v)
1682{
1683 return (v & 0x1fff) << 0;
1684}
1685static inline u32 gr_pd_ab_dist_cfg2_token_limit_init_v(void)
1686{
1687 return 0x000001c0;
1688}
1689static inline u32 gr_pd_ab_dist_cfg2_state_limit_f(u32 v)
1690{
1691 return (v & 0x1fff) << 16;
1692}
1693static inline u32 gr_pd_ab_dist_cfg2_state_limit_scc_bundle_granularity_v(void)
1694{
1695 return 0x00000020;
1696}
1697static inline u32 gr_pd_ab_dist_cfg2_state_limit_min_gpm_fifo_depths_v(void)
1698{
1699 return 0x00000182;
1700}
1701static inline u32 gr_pd_dist_skip_table_r(u32 i)
1702{
1703 return 0x004064d0 + i*4;
1704}
1705static inline u32 gr_pd_dist_skip_table__size_1_v(void)
1706{
1707 return 0x00000008;
1708}
1709static inline u32 gr_pd_dist_skip_table_gpc_4n0_mask_f(u32 v)
1710{
1711 return (v & 0xff) << 0;
1712}
1713static inline u32 gr_pd_dist_skip_table_gpc_4n1_mask_f(u32 v)
1714{
1715 return (v & 0xff) << 8;
1716}
1717static inline u32 gr_pd_dist_skip_table_gpc_4n2_mask_f(u32 v)
1718{
1719 return (v & 0xff) << 16;
1720}
1721static inline u32 gr_pd_dist_skip_table_gpc_4n3_mask_f(u32 v)
1722{
1723 return (v & 0xff) << 24;
1724}
1725static inline u32 gr_ds_debug_r(void)
1726{
1727 return 0x00405800;
1728}
1729static inline u32 gr_ds_debug_timeslice_mode_disable_f(void)
1730{
1731 return 0x0;
1732}
1733static inline u32 gr_ds_debug_timeslice_mode_enable_f(void)
1734{
1735 return 0x8000000;
1736}
1737static inline u32 gr_ds_zbc_color_r_r(void)
1738{
1739 return 0x00405804;
1740}
1741static inline u32 gr_ds_zbc_color_r_val_f(u32 v)
1742{
1743 return (v & 0xffffffff) << 0;
1744}
1745static inline u32 gr_ds_zbc_color_g_r(void)
1746{
1747 return 0x00405808;
1748}
1749static inline u32 gr_ds_zbc_color_g_val_f(u32 v)
1750{
1751 return (v & 0xffffffff) << 0;
1752}
1753static inline u32 gr_ds_zbc_color_b_r(void)
1754{
1755 return 0x0040580c;
1756}
1757static inline u32 gr_ds_zbc_color_b_val_f(u32 v)
1758{
1759 return (v & 0xffffffff) << 0;
1760}
1761static inline u32 gr_ds_zbc_color_a_r(void)
1762{
1763 return 0x00405810;
1764}
1765static inline u32 gr_ds_zbc_color_a_val_f(u32 v)
1766{
1767 return (v & 0xffffffff) << 0;
1768}
1769static inline u32 gr_ds_zbc_color_fmt_r(void)
1770{
1771 return 0x00405814;
1772}
1773static inline u32 gr_ds_zbc_color_fmt_val_f(u32 v)
1774{
1775 return (v & 0x7f) << 0;
1776}
1777static inline u32 gr_ds_zbc_color_fmt_val_invalid_f(void)
1778{
1779 return 0x0;
1780}
1781static inline u32 gr_ds_zbc_color_fmt_val_zero_v(void)
1782{
1783 return 0x00000001;
1784}
1785static inline u32 gr_ds_zbc_color_fmt_val_unorm_one_v(void)
1786{
1787 return 0x00000002;
1788}
1789static inline u32 gr_ds_zbc_color_fmt_val_rf32_gf32_bf32_af32_v(void)
1790{
1791 return 0x00000004;
1792}
1793static inline u32 gr_ds_zbc_color_fmt_val_a8_b8_g8_r8_v(void)
1794{
1795 return 0x00000028;
1796}
1797static inline u32 gr_ds_zbc_z_r(void)
1798{
1799 return 0x00405818;
1800}
1801static inline u32 gr_ds_zbc_z_val_s(void)
1802{
1803 return 32;
1804}
1805static inline u32 gr_ds_zbc_z_val_f(u32 v)
1806{
1807 return (v & 0xffffffff) << 0;
1808}
1809static inline u32 gr_ds_zbc_z_val_m(void)
1810{
1811 return 0xffffffff << 0;
1812}
1813static inline u32 gr_ds_zbc_z_val_v(u32 r)
1814{
1815 return (r >> 0) & 0xffffffff;
1816}
1817static inline u32 gr_ds_zbc_z_val__init_v(void)
1818{
1819 return 0x00000000;
1820}
1821static inline u32 gr_ds_zbc_z_val__init_f(void)
1822{
1823 return 0x0;
1824}
1825static inline u32 gr_ds_zbc_z_fmt_r(void)
1826{
1827 return 0x0040581c;
1828}
1829static inline u32 gr_ds_zbc_z_fmt_val_f(u32 v)
1830{
1831 return (v & 0x1) << 0;
1832}
1833static inline u32 gr_ds_zbc_z_fmt_val_invalid_f(void)
1834{
1835 return 0x0;
1836}
1837static inline u32 gr_ds_zbc_z_fmt_val_fp32_v(void)
1838{
1839 return 0x00000001;
1840}
1841static inline u32 gr_ds_zbc_tbl_index_r(void)
1842{
1843 return 0x00405820;
1844}
1845static inline u32 gr_ds_zbc_tbl_index_val_f(u32 v)
1846{
1847 return (v & 0xf) << 0;
1848}
1849static inline u32 gr_ds_zbc_tbl_ld_r(void)
1850{
1851 return 0x00405824;
1852}
1853static inline u32 gr_ds_zbc_tbl_ld_select_c_f(void)
1854{
1855 return 0x0;
1856}
1857static inline u32 gr_ds_zbc_tbl_ld_select_z_f(void)
1858{
1859 return 0x1;
1860}
1861static inline u32 gr_ds_zbc_tbl_ld_action_write_f(void)
1862{
1863 return 0x0;
1864}
1865static inline u32 gr_ds_zbc_tbl_ld_trigger_active_f(void)
1866{
1867 return 0x4;
1868}
1869static inline u32 gr_ds_tga_constraintlogic_beta_r(void)
1870{
1871 return 0x00405830;
1872}
1873static inline u32 gr_ds_tga_constraintlogic_beta_cbsize_f(u32 v)
1874{
1875 return (v & 0x3fffff) << 0;
1876}
1877static inline u32 gr_ds_tga_constraintlogic_alpha_r(void)
1878{
1879 return 0x0040585c;
1880}
1881static inline u32 gr_ds_tga_constraintlogic_alpha_cbsize_f(u32 v)
1882{
1883 return (v & 0xffff) << 0;
1884}
1885static inline u32 gr_ds_hww_esr_r(void)
1886{
1887 return 0x00405840;
1888}
1889static inline u32 gr_ds_hww_esr_reset_s(void)
1890{
1891 return 1;
1892}
1893static inline u32 gr_ds_hww_esr_reset_f(u32 v)
1894{
1895 return (v & 0x1) << 30;
1896}
1897static inline u32 gr_ds_hww_esr_reset_m(void)
1898{
1899 return 0x1 << 30;
1900}
1901static inline u32 gr_ds_hww_esr_reset_v(u32 r)
1902{
1903 return (r >> 30) & 0x1;
1904}
1905static inline u32 gr_ds_hww_esr_reset_task_v(void)
1906{
1907 return 0x00000001;
1908}
1909static inline u32 gr_ds_hww_esr_reset_task_f(void)
1910{
1911 return 0x40000000;
1912}
1913static inline u32 gr_ds_hww_esr_en_enabled_f(void)
1914{
1915 return 0x80000000;
1916}
1917static inline u32 gr_ds_hww_esr_2_r(void)
1918{
1919 return 0x00405848;
1920}
1921static inline u32 gr_ds_hww_esr_2_reset_s(void)
1922{
1923 return 1;
1924}
1925static inline u32 gr_ds_hww_esr_2_reset_f(u32 v)
1926{
1927 return (v & 0x1) << 30;
1928}
1929static inline u32 gr_ds_hww_esr_2_reset_m(void)
1930{
1931 return 0x1 << 30;
1932}
1933static inline u32 gr_ds_hww_esr_2_reset_v(u32 r)
1934{
1935 return (r >> 30) & 0x1;
1936}
1937static inline u32 gr_ds_hww_esr_2_reset_task_v(void)
1938{
1939 return 0x00000001;
1940}
1941static inline u32 gr_ds_hww_esr_2_reset_task_f(void)
1942{
1943 return 0x40000000;
1944}
1945static inline u32 gr_ds_hww_esr_2_en_enabled_f(void)
1946{
1947 return 0x80000000;
1948}
1949static inline u32 gr_ds_hww_report_mask_r(void)
1950{
1951 return 0x00405844;
1952}
1953static inline u32 gr_ds_hww_report_mask_sph0_err_report_f(void)
1954{
1955 return 0x1;
1956}
1957static inline u32 gr_ds_hww_report_mask_sph1_err_report_f(void)
1958{
1959 return 0x2;
1960}
1961static inline u32 gr_ds_hww_report_mask_sph2_err_report_f(void)
1962{
1963 return 0x4;
1964}
1965static inline u32 gr_ds_hww_report_mask_sph3_err_report_f(void)
1966{
1967 return 0x8;
1968}
1969static inline u32 gr_ds_hww_report_mask_sph4_err_report_f(void)
1970{
1971 return 0x10;
1972}
1973static inline u32 gr_ds_hww_report_mask_sph5_err_report_f(void)
1974{
1975 return 0x20;
1976}
1977static inline u32 gr_ds_hww_report_mask_sph6_err_report_f(void)
1978{
1979 return 0x40;
1980}
1981static inline u32 gr_ds_hww_report_mask_sph7_err_report_f(void)
1982{
1983 return 0x80;
1984}
1985static inline u32 gr_ds_hww_report_mask_sph8_err_report_f(void)
1986{
1987 return 0x100;
1988}
1989static inline u32 gr_ds_hww_report_mask_sph9_err_report_f(void)
1990{
1991 return 0x200;
1992}
1993static inline u32 gr_ds_hww_report_mask_sph10_err_report_f(void)
1994{
1995 return 0x400;
1996}
1997static inline u32 gr_ds_hww_report_mask_sph11_err_report_f(void)
1998{
1999 return 0x800;
2000}
2001static inline u32 gr_ds_hww_report_mask_sph12_err_report_f(void)
2002{
2003 return 0x1000;
2004}
2005static inline u32 gr_ds_hww_report_mask_sph13_err_report_f(void)
2006{
2007 return 0x2000;
2008}
2009static inline u32 gr_ds_hww_report_mask_sph14_err_report_f(void)
2010{
2011 return 0x4000;
2012}
2013static inline u32 gr_ds_hww_report_mask_sph15_err_report_f(void)
2014{
2015 return 0x8000;
2016}
2017static inline u32 gr_ds_hww_report_mask_sph16_err_report_f(void)
2018{
2019 return 0x10000;
2020}
2021static inline u32 gr_ds_hww_report_mask_sph17_err_report_f(void)
2022{
2023 return 0x20000;
2024}
2025static inline u32 gr_ds_hww_report_mask_sph18_err_report_f(void)
2026{
2027 return 0x40000;
2028}
2029static inline u32 gr_ds_hww_report_mask_sph19_err_report_f(void)
2030{
2031 return 0x80000;
2032}
2033static inline u32 gr_ds_hww_report_mask_sph20_err_report_f(void)
2034{
2035 return 0x100000;
2036}
2037static inline u32 gr_ds_hww_report_mask_sph21_err_report_f(void)
2038{
2039 return 0x200000;
2040}
2041static inline u32 gr_ds_hww_report_mask_sph22_err_report_f(void)
2042{
2043 return 0x400000;
2044}
2045static inline u32 gr_ds_hww_report_mask_sph23_err_report_f(void)
2046{
2047 return 0x800000;
2048}
2049static inline u32 gr_ds_hww_report_mask_2_r(void)
2050{
2051 return 0x0040584c;
2052}
2053static inline u32 gr_ds_hww_report_mask_2_sph24_err_report_f(void)
2054{
2055 return 0x1;
2056}
2057static inline u32 gr_ds_num_tpc_per_gpc_r(u32 i)
2058{
2059 return 0x00405870 + i*4;
2060}
2061static inline u32 gr_scc_bundle_cb_base_r(void)
2062{
2063 return 0x00408004;
2064}
2065static inline u32 gr_scc_bundle_cb_base_addr_39_8_f(u32 v)
2066{
2067 return (v & 0xffffffff) << 0;
2068}
2069static inline u32 gr_scc_bundle_cb_base_addr_39_8_align_bits_v(void)
2070{
2071 return 0x00000008;
2072}
2073static inline u32 gr_scc_bundle_cb_size_r(void)
2074{
2075 return 0x00408008;
2076}
2077static inline u32 gr_scc_bundle_cb_size_div_256b_f(u32 v)
2078{
2079 return (v & 0x7ff) << 0;
2080}
2081static inline u32 gr_scc_bundle_cb_size_div_256b__prod_v(void)
2082{
2083 return 0x00000018;
2084}
2085static inline u32 gr_scc_bundle_cb_size_div_256b_byte_granularity_v(void)
2086{
2087 return 0x00000100;
2088}
2089static inline u32 gr_scc_bundle_cb_size_valid_false_v(void)
2090{
2091 return 0x00000000;
2092}
2093static inline u32 gr_scc_bundle_cb_size_valid_false_f(void)
2094{
2095 return 0x0;
2096}
2097static inline u32 gr_scc_bundle_cb_size_valid_true_f(void)
2098{
2099 return 0x80000000;
2100}
2101static inline u32 gr_scc_pagepool_base_r(void)
2102{
2103 return 0x0040800c;
2104}
2105static inline u32 gr_scc_pagepool_base_addr_39_8_f(u32 v)
2106{
2107 return (v & 0xffffffff) << 0;
2108}
2109static inline u32 gr_scc_pagepool_base_addr_39_8_align_bits_v(void)
2110{
2111 return 0x00000008;
2112}
2113static inline u32 gr_scc_pagepool_r(void)
2114{
2115 return 0x00408010;
2116}
2117static inline u32 gr_scc_pagepool_total_pages_f(u32 v)
2118{
2119 return (v & 0x3ff) << 0;
2120}
2121static inline u32 gr_scc_pagepool_total_pages_hwmax_v(void)
2122{
2123 return 0x00000000;
2124}
2125static inline u32 gr_scc_pagepool_total_pages_hwmax_value_v(void)
2126{
2127 return 0x00000200;
2128}
2129static inline u32 gr_scc_pagepool_total_pages_byte_granularity_v(void)
2130{
2131 return 0x00000100;
2132}
2133static inline u32 gr_scc_pagepool_max_valid_pages_s(void)
2134{
2135 return 10;
2136}
2137static inline u32 gr_scc_pagepool_max_valid_pages_f(u32 v)
2138{
2139 return (v & 0x3ff) << 10;
2140}
2141static inline u32 gr_scc_pagepool_max_valid_pages_m(void)
2142{
2143 return 0x3ff << 10;
2144}
2145static inline u32 gr_scc_pagepool_max_valid_pages_v(u32 r)
2146{
2147 return (r >> 10) & 0x3ff;
2148}
2149static inline u32 gr_scc_pagepool_valid_true_f(void)
2150{
2151 return 0x80000000;
2152}
2153static inline u32 gr_scc_init_r(void)
2154{
2155 return 0x0040802c;
2156}
2157static inline u32 gr_scc_init_ram_trigger_f(void)
2158{
2159 return 0x1;
2160}
2161static inline u32 gr_scc_hww_esr_r(void)
2162{
2163 return 0x00408030;
2164}
2165static inline u32 gr_scc_hww_esr_reset_active_f(void)
2166{
2167 return 0x40000000;
2168}
2169static inline u32 gr_scc_hww_esr_en_enable_f(void)
2170{
2171 return 0x80000000;
2172}
2173static inline u32 gr_sked_hww_esr_r(void)
2174{
2175 return 0x00407020;
2176}
2177static inline u32 gr_sked_hww_esr_reset_active_f(void)
2178{
2179 return 0x40000000;
2180}
2181static inline u32 gr_cwd_fs_r(void)
2182{
2183 return 0x00405b00;
2184}
2185static inline u32 gr_cwd_fs_num_gpcs_f(u32 v)
2186{
2187 return (v & 0xff) << 0;
2188}
2189static inline u32 gr_cwd_fs_num_tpcs_f(u32 v)
2190{
2191 return (v & 0xff) << 8;
2192}
2193static inline u32 gr_cwd_gpc_tpc_id_r(u32 i)
2194{
2195 return 0x00405b60 + i*4;
2196}
2197static inline u32 gr_cwd_gpc_tpc_id_tpc0_s(void)
2198{
2199 return 4;
2200}
2201static inline u32 gr_cwd_gpc_tpc_id_tpc0_f(u32 v)
2202{
2203 return (v & 0xf) << 0;
2204}
2205static inline u32 gr_cwd_gpc_tpc_id_gpc0_s(void)
2206{
2207 return 4;
2208}
2209static inline u32 gr_cwd_gpc_tpc_id_gpc0_f(u32 v)
2210{
2211 return (v & 0xf) << 4;
2212}
2213static inline u32 gr_cwd_gpc_tpc_id_tpc1_f(u32 v)
2214{
2215 return (v & 0xf) << 8;
2216}
2217static inline u32 gr_cwd_sm_id_r(u32 i)
2218{
2219 return 0x00405ba0 + i*4;
2220}
2221static inline u32 gr_cwd_sm_id__size_1_v(void)
2222{
2223 return 0x00000010;
2224}
2225static inline u32 gr_cwd_sm_id_tpc0_f(u32 v)
2226{
2227 return (v & 0xff) << 0;
2228}
2229static inline u32 gr_cwd_sm_id_tpc1_f(u32 v)
2230{
2231 return (v & 0xff) << 8;
2232}
2233static inline u32 gr_gpc0_fs_gpc_r(void)
2234{
2235 return 0x00502608;
2236}
2237static inline u32 gr_gpc0_fs_gpc_num_available_tpcs_v(u32 r)
2238{
2239 return (r >> 0) & 0x1f;
2240}
2241static inline u32 gr_gpc0_fs_gpc_num_available_zculls_v(u32 r)
2242{
2243 return (r >> 16) & 0x1f;
2244}
2245static inline u32 gr_gpc0_cfg_r(void)
2246{
2247 return 0x00502620;
2248}
2249static inline u32 gr_gpc0_cfg_imem_sz_v(u32 r)
2250{
2251 return (r >> 0) & 0xff;
2252}
2253static inline u32 gr_gpccs_rc_lanes_r(void)
2254{
2255 return 0x00502880;
2256}
2257static inline u32 gr_gpccs_rc_lanes_num_chains_s(void)
2258{
2259 return 6;
2260}
2261static inline u32 gr_gpccs_rc_lanes_num_chains_f(u32 v)
2262{
2263 return (v & 0x3f) << 0;
2264}
2265static inline u32 gr_gpccs_rc_lanes_num_chains_m(void)
2266{
2267 return 0x3f << 0;
2268}
2269static inline u32 gr_gpccs_rc_lanes_num_chains_v(u32 r)
2270{
2271 return (r >> 0) & 0x3f;
2272}
2273static inline u32 gr_gpccs_rc_lane_size_r(void)
2274{
2275 return 0x00502910;
2276}
2277static inline u32 gr_gpccs_rc_lane_size_v_s(void)
2278{
2279 return 24;
2280}
2281static inline u32 gr_gpccs_rc_lane_size_v_f(u32 v)
2282{
2283 return (v & 0xffffff) << 0;
2284}
2285static inline u32 gr_gpccs_rc_lane_size_v_m(void)
2286{
2287 return 0xffffff << 0;
2288}
2289static inline u32 gr_gpccs_rc_lane_size_v_v(u32 r)
2290{
2291 return (r >> 0) & 0xffffff;
2292}
2293static inline u32 gr_gpccs_rc_lane_size_v_0_v(void)
2294{
2295 return 0x00000000;
2296}
2297static inline u32 gr_gpccs_rc_lane_size_v_0_f(void)
2298{
2299 return 0x0;
2300}
2301static inline u32 gr_gpc0_zcull_fs_r(void)
2302{
2303 return 0x00500910;
2304}
2305static inline u32 gr_gpc0_zcull_fs_num_sms_f(u32 v)
2306{
2307 return (v & 0x1ff) << 0;
2308}
2309static inline u32 gr_gpc0_zcull_fs_num_active_banks_f(u32 v)
2310{
2311 return (v & 0xf) << 16;
2312}
2313static inline u32 gr_gpc0_zcull_ram_addr_r(void)
2314{
2315 return 0x00500914;
2316}
2317static inline u32 gr_gpc0_zcull_ram_addr_tiles_per_hypertile_row_per_gpc_f(u32 v)
2318{
2319 return (v & 0xf) << 0;
2320}
2321static inline u32 gr_gpc0_zcull_ram_addr_row_offset_f(u32 v)
2322{
2323 return (v & 0xf) << 8;
2324}
2325static inline u32 gr_gpc0_zcull_sm_num_rcp_r(void)
2326{
2327 return 0x00500918;
2328}
2329static inline u32 gr_gpc0_zcull_sm_num_rcp_conservative_f(u32 v)
2330{
2331 return (v & 0xffffff) << 0;
2332}
2333static inline u32 gr_gpc0_zcull_sm_num_rcp_conservative__max_v(void)
2334{
2335 return 0x00800000;
2336}
2337static inline u32 gr_gpc0_zcull_total_ram_size_r(void)
2338{
2339 return 0x00500920;
2340}
2341static inline u32 gr_gpc0_zcull_total_ram_size_num_aliquots_f(u32 v)
2342{
2343 return (v & 0xffff) << 0;
2344}
2345static inline u32 gr_gpc0_zcull_zcsize_r(u32 i)
2346{
2347 return 0x00500a04 + i*32;
2348}
2349static inline u32 gr_gpc0_zcull_zcsize_height_subregion__multiple_v(void)
2350{
2351 return 0x00000040;
2352}
2353static inline u32 gr_gpc0_zcull_zcsize_width_subregion__multiple_v(void)
2354{
2355 return 0x00000010;
2356}
2357static inline u32 gr_gpc0_gpm_pd_sm_id_r(u32 i)
2358{
2359 return 0x00500c10 + i*4;
2360}
2361static inline u32 gr_gpc0_gpm_pd_sm_id_id_f(u32 v)
2362{
2363 return (v & 0xff) << 0;
2364}
2365static inline u32 gr_gpc0_gpm_pd_pes_tpc_id_mask_r(u32 i)
2366{
2367 return 0x00500c30 + i*4;
2368}
2369static inline u32 gr_gpc0_gpm_pd_pes_tpc_id_mask_mask_v(u32 r)
2370{
2371 return (r >> 0) & 0xff;
2372}
2373static inline u32 gr_gpc0_tpc0_pe_cfg_smid_r(void)
2374{
2375 return 0x00504088;
2376}
2377static inline u32 gr_gpc0_tpc0_pe_cfg_smid_value_f(u32 v)
2378{
2379 return (v & 0xffff) << 0;
2380}
2381static inline u32 gr_gpc0_tpc0_sm_cfg_r(void)
2382{
2383 return 0x00504698;
2384}
2385static inline u32 gr_gpc0_tpc0_sm_cfg_sm_id_f(u32 v)
2386{
2387 return (v & 0xffff) << 0;
2388}
2389static inline u32 gr_gpc0_tpc0_sm_cfg_sm_id_v(u32 r)
2390{
2391 return (r >> 0) & 0xffff;
2392}
2393static inline u32 gr_gpc0_tpc0_sm_arch_r(void)
2394{
2395 return 0x0050469c;
2396}
2397static inline u32 gr_gpc0_tpc0_sm_arch_warp_count_v(u32 r)
2398{
2399 return (r >> 0) & 0xff;
2400}
2401static inline u32 gr_gpc0_tpc0_sm_arch_spa_version_v(u32 r)
2402{
2403 return (r >> 8) & 0xfff;
2404}
2405static inline u32 gr_gpc0_tpc0_sm_arch_sm_version_v(u32 r)
2406{
2407 return (r >> 20) & 0xfff;
2408}
2409static inline u32 gr_gpc0_ppc0_pes_vsc_strem_r(void)
2410{
2411 return 0x00503018;
2412}
2413static inline u32 gr_gpc0_ppc0_pes_vsc_strem_master_pe_m(void)
2414{
2415 return 0x1 << 0;
2416}
2417static inline u32 gr_gpc0_ppc0_pes_vsc_strem_master_pe_true_f(void)
2418{
2419 return 0x1;
2420}
2421static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_r(void)
2422{
2423 return 0x005030c0;
2424}
2425static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_f(u32 v)
2426{
2427 return (v & 0x3fffff) << 0;
2428}
2429static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_m(void)
2430{
2431 return 0x3fffff << 0;
2432}
2433static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v(void)
2434{
2435 return 0x00030000;
2436}
2437static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v(void)
2438{
2439 return 0x00030a00;
2440}
2441static inline u32 gr_gpc0_ppc0_cbm_beta_cb_size_v_granularity_v(void)
2442{
2443 return 0x00000020;
2444}
2445static inline u32 gr_gpc0_ppc0_cbm_beta_cb_offset_r(void)
2446{
2447 return 0x005030f4;
2448}
2449static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_r(void)
2450{
2451 return 0x005030e4;
2452}
2453static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_v_f(u32 v)
2454{
2455 return (v & 0xffff) << 0;
2456}
2457static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_v_m(void)
2458{
2459 return 0xffff << 0;
2460}
2461static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_v_default_v(void)
2462{
2463 return 0x00000800;
2464}
2465static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_size_v_granularity_v(void)
2466{
2467 return 0x00000020;
2468}
2469static inline u32 gr_gpc0_ppc0_cbm_alpha_cb_offset_r(void)
2470{
2471 return 0x005030f8;
2472}
2473static inline u32 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_r(void)
2474{
2475 return 0x005030f0;
2476}
2477static inline u32 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_v_f(u32 v)
2478{
2479 return (v & 0x3fffff) << 0;
2480}
2481static inline u32 gr_gpc0_ppc0_cbm_beta_steady_state_cb_size_v_default_v(void)
2482{
2483 return 0x00030000;
2484}
2485static inline u32 gr_gpcs_tpcs_tex_rm_cb_0_r(void)
2486{
2487 return 0x00419b00;
2488}
2489static inline u32 gr_gpcs_tpcs_tex_rm_cb_0_base_addr_43_12_f(u32 v)
2490{
2491 return (v & 0xffffffff) << 0;
2492}
2493static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_r(void)
2494{
2495 return 0x00419b04;
2496}
2497static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_s(void)
2498{
2499 return 21;
2500}
2501static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_f(u32 v)
2502{
2503 return (v & 0x1fffff) << 0;
2504}
2505static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_m(void)
2506{
2507 return 0x1fffff << 0;
2508}
2509static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_v(u32 r)
2510{
2511 return (r >> 0) & 0x1fffff;
2512}
2513static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_size_div_128b_granularity_f(void)
2514{
2515 return 0x80;
2516}
2517static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_s(void)
2518{
2519 return 1;
2520}
2521static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_f(u32 v)
2522{
2523 return (v & 0x1) << 31;
2524}
2525static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_m(void)
2526{
2527 return 0x1 << 31;
2528}
2529static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_v(u32 r)
2530{
2531 return (r >> 31) & 0x1;
2532}
2533static inline u32 gr_gpcs_tpcs_tex_rm_cb_1_valid_true_f(void)
2534{
2535 return 0x80000000;
2536}
2537static inline u32 gr_gpccs_falcon_addr_r(void)
2538{
2539 return 0x0041a0ac;
2540}
2541static inline u32 gr_gpccs_falcon_addr_lsb_s(void)
2542{
2543 return 6;
2544}
2545static inline u32 gr_gpccs_falcon_addr_lsb_f(u32 v)
2546{
2547 return (v & 0x3f) << 0;
2548}
2549static inline u32 gr_gpccs_falcon_addr_lsb_m(void)
2550{
2551 return 0x3f << 0;
2552}
2553static inline u32 gr_gpccs_falcon_addr_lsb_v(u32 r)
2554{
2555 return (r >> 0) & 0x3f;
2556}
2557static inline u32 gr_gpccs_falcon_addr_lsb_init_v(void)
2558{
2559 return 0x00000000;
2560}
2561static inline u32 gr_gpccs_falcon_addr_lsb_init_f(void)
2562{
2563 return 0x0;
2564}
2565static inline u32 gr_gpccs_falcon_addr_msb_s(void)
2566{
2567 return 6;
2568}
2569static inline u32 gr_gpccs_falcon_addr_msb_f(u32 v)
2570{
2571 return (v & 0x3f) << 6;
2572}
2573static inline u32 gr_gpccs_falcon_addr_msb_m(void)
2574{
2575 return 0x3f << 6;
2576}
2577static inline u32 gr_gpccs_falcon_addr_msb_v(u32 r)
2578{
2579 return (r >> 6) & 0x3f;
2580}
2581static inline u32 gr_gpccs_falcon_addr_msb_init_v(void)
2582{
2583 return 0x00000000;
2584}
2585static inline u32 gr_gpccs_falcon_addr_msb_init_f(void)
2586{
2587 return 0x0;
2588}
2589static inline u32 gr_gpccs_falcon_addr_ext_s(void)
2590{
2591 return 12;
2592}
2593static inline u32 gr_gpccs_falcon_addr_ext_f(u32 v)
2594{
2595 return (v & 0xfff) << 0;
2596}
2597static inline u32 gr_gpccs_falcon_addr_ext_m(void)
2598{
2599 return 0xfff << 0;
2600}
2601static inline u32 gr_gpccs_falcon_addr_ext_v(u32 r)
2602{
2603 return (r >> 0) & 0xfff;
2604}
2605static inline u32 gr_gpccs_cpuctl_r(void)
2606{
2607 return 0x0041a100;
2608}
2609static inline u32 gr_gpccs_cpuctl_startcpu_f(u32 v)
2610{
2611 return (v & 0x1) << 1;
2612}
2613static inline u32 gr_gpccs_dmactl_r(void)
2614{
2615 return 0x0041a10c;
2616}
2617static inline u32 gr_gpccs_dmactl_require_ctx_f(u32 v)
2618{
2619 return (v & 0x1) << 0;
2620}
2621static inline u32 gr_gpccs_dmactl_dmem_scrubbing_m(void)
2622{
2623 return 0x1 << 1;
2624}
2625static inline u32 gr_gpccs_dmactl_imem_scrubbing_m(void)
2626{
2627 return 0x1 << 2;
2628}
2629static inline u32 gr_gpccs_imemc_r(u32 i)
2630{
2631 return 0x0041a180 + i*16;
2632}
2633static inline u32 gr_gpccs_imemc_offs_f(u32 v)
2634{
2635 return (v & 0x3f) << 2;
2636}
2637static inline u32 gr_gpccs_imemc_blk_f(u32 v)
2638{
2639 return (v & 0xff) << 8;
2640}
2641static inline u32 gr_gpccs_imemc_aincw_f(u32 v)
2642{
2643 return (v & 0x1) << 24;
2644}
2645static inline u32 gr_gpccs_imemd_r(u32 i)
2646{
2647 return 0x0041a184 + i*16;
2648}
2649static inline u32 gr_gpccs_imemt_r(u32 i)
2650{
2651 return 0x0041a188 + i*16;
2652}
2653static inline u32 gr_gpccs_imemt__size_1_v(void)
2654{
2655 return 0x00000004;
2656}
2657static inline u32 gr_gpccs_imemt_tag_f(u32 v)
2658{
2659 return (v & 0xffff) << 0;
2660}
2661static inline u32 gr_gpccs_dmemc_r(u32 i)
2662{
2663 return 0x0041a1c0 + i*8;
2664}
2665static inline u32 gr_gpccs_dmemc_offs_f(u32 v)
2666{
2667 return (v & 0x3f) << 2;
2668}
2669static inline u32 gr_gpccs_dmemc_blk_f(u32 v)
2670{
2671 return (v & 0xff) << 8;
2672}
2673static inline u32 gr_gpccs_dmemc_aincw_f(u32 v)
2674{
2675 return (v & 0x1) << 24;
2676}
2677static inline u32 gr_gpccs_dmemd_r(u32 i)
2678{
2679 return 0x0041a1c4 + i*8;
2680}
2681static inline u32 gr_gpccs_ctxsw_mailbox_r(u32 i)
2682{
2683 return 0x0041a800 + i*4;
2684}
2685static inline u32 gr_gpccs_ctxsw_mailbox_value_f(u32 v)
2686{
2687 return (v & 0xffffffff) << 0;
2688}
2689static inline u32 gr_gpcs_swdx_bundle_cb_base_r(void)
2690{
2691 return 0x00418e24;
2692}
2693static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_s(void)
2694{
2695 return 32;
2696}
2697static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_f(u32 v)
2698{
2699 return (v & 0xffffffff) << 0;
2700}
2701static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_m(void)
2702{
2703 return 0xffffffff << 0;
2704}
2705static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_v(u32 r)
2706{
2707 return (r >> 0) & 0xffffffff;
2708}
2709static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_init_v(void)
2710{
2711 return 0x00000000;
2712}
2713static inline u32 gr_gpcs_swdx_bundle_cb_base_addr_39_8_init_f(void)
2714{
2715 return 0x0;
2716}
2717static inline u32 gr_gpcs_swdx_bundle_cb_size_r(void)
2718{
2719 return 0x00418e28;
2720}
2721static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_s(void)
2722{
2723 return 11;
2724}
2725static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_f(u32 v)
2726{
2727 return (v & 0x7ff) << 0;
2728}
2729static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_m(void)
2730{
2731 return 0x7ff << 0;
2732}
2733static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_v(u32 r)
2734{
2735 return (r >> 0) & 0x7ff;
2736}
2737static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_init_v(void)
2738{
2739 return 0x00000018;
2740}
2741static inline u32 gr_gpcs_swdx_bundle_cb_size_div_256b_init_f(void)
2742{
2743 return 0x18;
2744}
2745static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_s(void)
2746{
2747 return 1;
2748}
2749static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_f(u32 v)
2750{
2751 return (v & 0x1) << 31;
2752}
2753static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_m(void)
2754{
2755 return 0x1 << 31;
2756}
2757static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_v(u32 r)
2758{
2759 return (r >> 31) & 0x1;
2760}
2761static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_false_v(void)
2762{
2763 return 0x00000000;
2764}
2765static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_false_f(void)
2766{
2767 return 0x0;
2768}
2769static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_true_v(void)
2770{
2771 return 0x00000001;
2772}
2773static inline u32 gr_gpcs_swdx_bundle_cb_size_valid_true_f(void)
2774{
2775 return 0x80000000;
2776}
2777static inline u32 gr_gpc0_swdx_rm_spill_buffer_size_r(void)
2778{
2779 return 0x00500ee4;
2780}
2781static inline u32 gr_gpc0_swdx_rm_spill_buffer_size_256b_f(u32 v)
2782{
2783 return (v & 0xffff) << 0;
2784}
2785static inline u32 gr_gpc0_swdx_rm_spill_buffer_size_256b_default_v(void)
2786{
2787 return 0x00000250;
2788}
2789static inline u32 gr_gpc0_swdx_rm_spill_buffer_size_256b_byte_granularity_v(void)
2790{
2791 return 0x00000100;
2792}
2793static inline u32 gr_gpc0_swdx_rm_spill_buffer_addr_r(void)
2794{
2795 return 0x00500ee0;
2796}
2797static inline u32 gr_gpc0_swdx_rm_spill_buffer_addr_39_8_f(u32 v)
2798{
2799 return (v & 0xffffffff) << 0;
2800}
2801static inline u32 gr_gpc0_swdx_rm_spill_buffer_addr_39_8_align_bits_v(void)
2802{
2803 return 0x00000008;
2804}
2805static inline u32 gr_gpcs_swdx_beta_cb_ctrl_r(void)
2806{
2807 return 0x00418eec;
2808}
2809static inline u32 gr_gpcs_swdx_beta_cb_ctrl_cbes_reserve_f(u32 v)
2810{
2811 return (v & 0xfff) << 0;
2812}
2813static inline u32 gr_gpcs_swdx_beta_cb_ctrl_cbes_reserve_gfxp_v(void)
2814{
2815 return 0x00000100;
2816}
2817static inline u32 gr_gpcs_ppcs_cbm_beta_cb_ctrl_r(void)
2818{
2819 return 0x0041befc;
2820}
2821static inline u32 gr_gpcs_ppcs_cbm_beta_cb_ctrl_cbes_reserve_f(u32 v)
2822{
2823 return (v & 0xfff) << 0;
2824}
2825static inline u32 gr_gpcs_swdx_tc_beta_cb_size_r(u32 i)
2826{
2827 return 0x00418ea0 + i*4;
2828}
2829static inline u32 gr_gpcs_swdx_tc_beta_cb_size_v_f(u32 v)
2830{
2831 return (v & 0x3fffff) << 0;
2832}
2833static inline u32 gr_gpcs_swdx_tc_beta_cb_size_v_m(void)
2834{
2835 return 0x3fffff << 0;
2836}
2837static inline u32 gr_gpcs_swdx_dss_zbc_color_r_r(u32 i)
2838{
2839 return 0x00418010 + i*4;
2840}
2841static inline u32 gr_gpcs_swdx_dss_zbc_color_r_val_f(u32 v)
2842{
2843 return (v & 0xffffffff) << 0;
2844}
2845static inline u32 gr_gpcs_swdx_dss_zbc_color_g_r(u32 i)
2846{
2847 return 0x0041804c + i*4;
2848}
2849static inline u32 gr_gpcs_swdx_dss_zbc_color_g_val_f(u32 v)
2850{
2851 return (v & 0xffffffff) << 0;
2852}
2853static inline u32 gr_gpcs_swdx_dss_zbc_color_b_r(u32 i)
2854{
2855 return 0x00418088 + i*4;
2856}
2857static inline u32 gr_gpcs_swdx_dss_zbc_color_b_val_f(u32 v)
2858{
2859 return (v & 0xffffffff) << 0;
2860}
2861static inline u32 gr_gpcs_swdx_dss_zbc_color_a_r(u32 i)
2862{
2863 return 0x004180c4 + i*4;
2864}
2865static inline u32 gr_gpcs_swdx_dss_zbc_color_a_val_f(u32 v)
2866{
2867 return (v & 0xffffffff) << 0;
2868}
2869static inline u32 gr_gpcs_swdx_dss_zbc_c_01_to_04_format_r(void)
2870{
2871 return 0x00500100;
2872}
2873static inline u32 gr_gpcs_swdx_dss_zbc_z_r(u32 i)
2874{
2875 return 0x00418110 + i*4;
2876}
2877static inline u32 gr_gpcs_swdx_dss_zbc_z_val_f(u32 v)
2878{
2879 return (v & 0xffffffff) << 0;
2880}
2881static inline u32 gr_gpcs_swdx_dss_zbc_z_01_to_04_format_r(void)
2882{
2883 return 0x0050014c;
2884}
2885static inline u32 gr_gpcs_setup_attrib_cb_base_r(void)
2886{
2887 return 0x00418810;
2888}
2889static inline u32 gr_gpcs_setup_attrib_cb_base_addr_39_12_f(u32 v)
2890{
2891 return (v & 0xfffffff) << 0;
2892}
2893static inline u32 gr_gpcs_setup_attrib_cb_base_addr_39_12_align_bits_v(void)
2894{
2895 return 0x0000000c;
2896}
2897static inline u32 gr_gpcs_setup_attrib_cb_base_valid_true_f(void)
2898{
2899 return 0x80000000;
2900}
2901static inline u32 gr_crstr_gpc_map0_r(void)
2902{
2903 return 0x00418b08;
2904}
2905static inline u32 gr_crstr_gpc_map0_tile0_f(u32 v)
2906{
2907 return (v & 0x7) << 0;
2908}
2909static inline u32 gr_crstr_gpc_map0_tile1_f(u32 v)
2910{
2911 return (v & 0x7) << 5;
2912}
2913static inline u32 gr_crstr_gpc_map0_tile2_f(u32 v)
2914{
2915 return (v & 0x7) << 10;
2916}
2917static inline u32 gr_crstr_gpc_map0_tile3_f(u32 v)
2918{
2919 return (v & 0x7) << 15;
2920}
2921static inline u32 gr_crstr_gpc_map0_tile4_f(u32 v)
2922{
2923 return (v & 0x7) << 20;
2924}
2925static inline u32 gr_crstr_gpc_map0_tile5_f(u32 v)
2926{
2927 return (v & 0x7) << 25;
2928}
2929static inline u32 gr_crstr_gpc_map1_r(void)
2930{
2931 return 0x00418b0c;
2932}
2933static inline u32 gr_crstr_gpc_map1_tile6_f(u32 v)
2934{
2935 return (v & 0x7) << 0;
2936}
2937static inline u32 gr_crstr_gpc_map1_tile7_f(u32 v)
2938{
2939 return (v & 0x7) << 5;
2940}
2941static inline u32 gr_crstr_gpc_map1_tile8_f(u32 v)
2942{
2943 return (v & 0x7) << 10;
2944}
2945static inline u32 gr_crstr_gpc_map1_tile9_f(u32 v)
2946{
2947 return (v & 0x7) << 15;
2948}
2949static inline u32 gr_crstr_gpc_map1_tile10_f(u32 v)
2950{
2951 return (v & 0x7) << 20;
2952}
2953static inline u32 gr_crstr_gpc_map1_tile11_f(u32 v)
2954{
2955 return (v & 0x7) << 25;
2956}
2957static inline u32 gr_crstr_gpc_map2_r(void)
2958{
2959 return 0x00418b10;
2960}
2961static inline u32 gr_crstr_gpc_map2_tile12_f(u32 v)
2962{
2963 return (v & 0x7) << 0;
2964}
2965static inline u32 gr_crstr_gpc_map2_tile13_f(u32 v)
2966{
2967 return (v & 0x7) << 5;
2968}
2969static inline u32 gr_crstr_gpc_map2_tile14_f(u32 v)
2970{
2971 return (v & 0x7) << 10;
2972}
2973static inline u32 gr_crstr_gpc_map2_tile15_f(u32 v)
2974{
2975 return (v & 0x7) << 15;
2976}
2977static inline u32 gr_crstr_gpc_map2_tile16_f(u32 v)
2978{
2979 return (v & 0x7) << 20;
2980}
2981static inline u32 gr_crstr_gpc_map2_tile17_f(u32 v)
2982{
2983 return (v & 0x7) << 25;
2984}
2985static inline u32 gr_crstr_gpc_map3_r(void)
2986{
2987 return 0x00418b14;
2988}
2989static inline u32 gr_crstr_gpc_map3_tile18_f(u32 v)
2990{
2991 return (v & 0x7) << 0;
2992}
2993static inline u32 gr_crstr_gpc_map3_tile19_f(u32 v)
2994{
2995 return (v & 0x7) << 5;
2996}
2997static inline u32 gr_crstr_gpc_map3_tile20_f(u32 v)
2998{
2999 return (v & 0x7) << 10;
3000}
3001static inline u32 gr_crstr_gpc_map3_tile21_f(u32 v)
3002{
3003 return (v & 0x7) << 15;
3004}
3005static inline u32 gr_crstr_gpc_map3_tile22_f(u32 v)
3006{
3007 return (v & 0x7) << 20;
3008}
3009static inline u32 gr_crstr_gpc_map3_tile23_f(u32 v)
3010{
3011 return (v & 0x7) << 25;
3012}
3013static inline u32 gr_crstr_gpc_map4_r(void)
3014{
3015 return 0x00418b18;
3016}
3017static inline u32 gr_crstr_gpc_map4_tile24_f(u32 v)
3018{
3019 return (v & 0x7) << 0;
3020}
3021static inline u32 gr_crstr_gpc_map4_tile25_f(u32 v)
3022{
3023 return (v & 0x7) << 5;
3024}
3025static inline u32 gr_crstr_gpc_map4_tile26_f(u32 v)
3026{
3027 return (v & 0x7) << 10;
3028}
3029static inline u32 gr_crstr_gpc_map4_tile27_f(u32 v)
3030{
3031 return (v & 0x7) << 15;
3032}
3033static inline u32 gr_crstr_gpc_map4_tile28_f(u32 v)
3034{
3035 return (v & 0x7) << 20;
3036}
3037static inline u32 gr_crstr_gpc_map4_tile29_f(u32 v)
3038{
3039 return (v & 0x7) << 25;
3040}
3041static inline u32 gr_crstr_gpc_map5_r(void)
3042{
3043 return 0x00418b1c;
3044}
3045static inline u32 gr_crstr_gpc_map5_tile30_f(u32 v)
3046{
3047 return (v & 0x7) << 0;
3048}
3049static inline u32 gr_crstr_gpc_map5_tile31_f(u32 v)
3050{
3051 return (v & 0x7) << 5;
3052}
3053static inline u32 gr_crstr_gpc_map5_tile32_f(u32 v)
3054{
3055 return (v & 0x7) << 10;
3056}
3057static inline u32 gr_crstr_gpc_map5_tile33_f(u32 v)
3058{
3059 return (v & 0x7) << 15;
3060}
3061static inline u32 gr_crstr_gpc_map5_tile34_f(u32 v)
3062{
3063 return (v & 0x7) << 20;
3064}
3065static inline u32 gr_crstr_gpc_map5_tile35_f(u32 v)
3066{
3067 return (v & 0x7) << 25;
3068}
3069static inline u32 gr_crstr_map_table_cfg_r(void)
3070{
3071 return 0x00418bb8;
3072}
3073static inline u32 gr_crstr_map_table_cfg_row_offset_f(u32 v)
3074{
3075 return (v & 0xff) << 0;
3076}
3077static inline u32 gr_crstr_map_table_cfg_num_entries_f(u32 v)
3078{
3079 return (v & 0xff) << 8;
3080}
3081static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_r(void)
3082{
3083 return 0x00418980;
3084}
3085static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_0_f(u32 v)
3086{
3087 return (v & 0x7) << 0;
3088}
3089static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_1_f(u32 v)
3090{
3091 return (v & 0x7) << 4;
3092}
3093static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_2_f(u32 v)
3094{
3095 return (v & 0x7) << 8;
3096}
3097static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_3_f(u32 v)
3098{
3099 return (v & 0x7) << 12;
3100}
3101static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_4_f(u32 v)
3102{
3103 return (v & 0x7) << 16;
3104}
3105static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_5_f(u32 v)
3106{
3107 return (v & 0x7) << 20;
3108}
3109static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_6_f(u32 v)
3110{
3111 return (v & 0x7) << 24;
3112}
3113static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map0_tile_7_f(u32 v)
3114{
3115 return (v & 0x7) << 28;
3116}
3117static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_r(void)
3118{
3119 return 0x00418984;
3120}
3121static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_8_f(u32 v)
3122{
3123 return (v & 0x7) << 0;
3124}
3125static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_9_f(u32 v)
3126{
3127 return (v & 0x7) << 4;
3128}
3129static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_10_f(u32 v)
3130{
3131 return (v & 0x7) << 8;
3132}
3133static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_11_f(u32 v)
3134{
3135 return (v & 0x7) << 12;
3136}
3137static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_12_f(u32 v)
3138{
3139 return (v & 0x7) << 16;
3140}
3141static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_13_f(u32 v)
3142{
3143 return (v & 0x7) << 20;
3144}
3145static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_14_f(u32 v)
3146{
3147 return (v & 0x7) << 24;
3148}
3149static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map1_tile_15_f(u32 v)
3150{
3151 return (v & 0x7) << 28;
3152}
3153static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_r(void)
3154{
3155 return 0x00418988;
3156}
3157static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_16_f(u32 v)
3158{
3159 return (v & 0x7) << 0;
3160}
3161static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_17_f(u32 v)
3162{
3163 return (v & 0x7) << 4;
3164}
3165static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_18_f(u32 v)
3166{
3167 return (v & 0x7) << 8;
3168}
3169static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_19_f(u32 v)
3170{
3171 return (v & 0x7) << 12;
3172}
3173static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_20_f(u32 v)
3174{
3175 return (v & 0x7) << 16;
3176}
3177static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_21_f(u32 v)
3178{
3179 return (v & 0x7) << 20;
3180}
3181static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_22_f(u32 v)
3182{
3183 return (v & 0x7) << 24;
3184}
3185static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_23_s(void)
3186{
3187 return 3;
3188}
3189static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_23_f(u32 v)
3190{
3191 return (v & 0x7) << 28;
3192}
3193static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_23_m(void)
3194{
3195 return 0x7 << 28;
3196}
3197static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map2_tile_23_v(u32 r)
3198{
3199 return (r >> 28) & 0x7;
3200}
3201static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_r(void)
3202{
3203 return 0x0041898c;
3204}
3205static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_24_f(u32 v)
3206{
3207 return (v & 0x7) << 0;
3208}
3209static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_25_f(u32 v)
3210{
3211 return (v & 0x7) << 4;
3212}
3213static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_26_f(u32 v)
3214{
3215 return (v & 0x7) << 8;
3216}
3217static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_27_f(u32 v)
3218{
3219 return (v & 0x7) << 12;
3220}
3221static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_28_f(u32 v)
3222{
3223 return (v & 0x7) << 16;
3224}
3225static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_29_f(u32 v)
3226{
3227 return (v & 0x7) << 20;
3228}
3229static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_30_f(u32 v)
3230{
3231 return (v & 0x7) << 24;
3232}
3233static inline u32 gr_gpcs_zcull_sm_in_gpc_number_map3_tile_31_f(u32 v)
3234{
3235 return (v & 0x7) << 28;
3236}
3237static inline u32 gr_gpcs_gpm_pd_cfg_r(void)
3238{
3239 return 0x00418c6c;
3240}
3241static inline u32 gr_gpcs_gpm_pd_cfg_timeslice_mode_disable_f(void)
3242{
3243 return 0x0;
3244}
3245static inline u32 gr_gpcs_gpm_pd_cfg_timeslice_mode_enable_f(void)
3246{
3247 return 0x1;
3248}
3249static inline u32 gr_gpcs_gcc_pagepool_base_r(void)
3250{
3251 return 0x00419004;
3252}
3253static inline u32 gr_gpcs_gcc_pagepool_base_addr_39_8_f(u32 v)
3254{
3255 return (v & 0xffffffff) << 0;
3256}
3257static inline u32 gr_gpcs_gcc_pagepool_r(void)
3258{
3259 return 0x00419008;
3260}
3261static inline u32 gr_gpcs_gcc_pagepool_total_pages_f(u32 v)
3262{
3263 return (v & 0x3ff) << 0;
3264}
3265static inline u32 gr_gpcs_tpcs_pe_vaf_r(void)
3266{
3267 return 0x0041980c;
3268}
3269static inline u32 gr_gpcs_tpcs_pe_vaf_fast_mode_switch_true_f(void)
3270{
3271 return 0x10;
3272}
3273static inline u32 gr_gpcs_tpcs_pe_pin_cb_global_base_addr_r(void)
3274{
3275 return 0x00419848;
3276}
3277static inline u32 gr_gpcs_tpcs_pe_pin_cb_global_base_addr_v_f(u32 v)
3278{
3279 return (v & 0xfffffff) << 0;
3280}
3281static inline u32 gr_gpcs_tpcs_pe_pin_cb_global_base_addr_valid_f(u32 v)
3282{
3283 return (v & 0x1) << 28;
3284}
3285static inline u32 gr_gpcs_tpcs_pe_pin_cb_global_base_addr_valid_true_f(void)
3286{
3287 return 0x10000000;
3288}
3289static inline u32 gr_gpcs_tpcs_mpc_vtg_debug_r(void)
3290{
3291 return 0x00419c00;
3292}
3293static inline u32 gr_gpcs_tpcs_mpc_vtg_debug_timeslice_mode_disabled_f(void)
3294{
3295 return 0x0;
3296}
3297static inline u32 gr_gpcs_tpcs_mpc_vtg_debug_timeslice_mode_enabled_f(void)
3298{
3299 return 0x8;
3300}
3301static inline u32 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_r(void)
3302{
3303 return 0x00419c2c;
3304}
3305static inline u32 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_v_f(u32 v)
3306{
3307 return (v & 0xfffffff) << 0;
3308}
3309static inline u32 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_valid_f(u32 v)
3310{
3311 return (v & 0x1) << 28;
3312}
3313static inline u32 gr_gpcs_tpcs_mpc_vtg_cb_global_base_addr_valid_true_f(void)
3314{
3315 return 0x10000000;
3316}
3317static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_r(void)
3318{
3319 return 0x00419e44;
3320}
3321static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_stack_error_report_f(void)
3322{
3323 return 0x2;
3324}
3325static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_api_stack_error_report_f(void)
3326{
3327 return 0x4;
3328}
3329static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_ret_empty_stack_error_report_f(void)
3330{
3331 return 0x8;
3332}
3333static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_pc_wrap_report_f(void)
3334{
3335 return 0x10;
3336}
3337static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_misaligned_pc_report_f(void)
3338{
3339 return 0x20;
3340}
3341static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_pc_overflow_report_f(void)
3342{
3343 return 0x40;
3344}
3345static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_misaligned_immc_addr_report_f(void)
3346{
3347 return 0x80;
3348}
3349static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_misaligned_reg_report_f(void)
3350{
3351 return 0x100;
3352}
3353static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_illegal_instr_encoding_report_f(void)
3354{
3355 return 0x200;
3356}
3357static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_illegal_sph_instr_combo_report_f(void)
3358{
3359 return 0x400;
3360}
3361static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_illegal_instr_param_report_f(void)
3362{
3363 return 0x800;
3364}
3365static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_invalid_const_addr_report_f(void)
3366{
3367 return 0x1000;
3368}
3369static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_oor_reg_report_f(void)
3370{
3371 return 0x2000;
3372}
3373static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_oor_addr_report_f(void)
3374{
3375 return 0x4000;
3376}
3377static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_misaligned_addr_report_f(void)
3378{
3379 return 0x8000;
3380}
3381static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_invalid_addr_space_report_f(void)
3382{
3383 return 0x10000;
3384}
3385static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_illegal_instr_param2_report_f(void)
3386{
3387 return 0x20000;
3388}
3389static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_invalid_const_addr_ldc_report_f(void)
3390{
3391 return 0x40000;
3392}
3393static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_mmu_fault_report_f(void)
3394{
3395 return 0x800000;
3396}
3397static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_stack_overflow_report_f(void)
3398{
3399 return 0x400000;
3400}
3401static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_geometry_sm_error_report_f(void)
3402{
3403 return 0x80000;
3404}
3405static inline u32 gr_gpcs_tpcs_sm_hww_warp_esr_report_mask_divergent_report_f(void)
3406{
3407 return 0x100000;
3408}
3409static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_r(void)
3410{
3411 return 0x00419e4c;
3412}
3413static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_sm_to_sm_fault_report_f(void)
3414{
3415 return 0x1;
3416}
3417static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_l1_error_report_f(void)
3418{
3419 return 0x2;
3420}
3421static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_multiple_warp_errors_report_f(void)
3422{
3423 return 0x4;
3424}
3425static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_physical_stack_overflow_error_report_f(void)
3426{
3427 return 0x8;
3428}
3429static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_bpt_int_report_f(void)
3430{
3431 return 0x10;
3432}
3433static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_ecc_sec_error_report_f(void)
3434{
3435 return 0x20000000;
3436}
3437static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_ecc_ded_error_report_f(void)
3438{
3439 return 0x40000000;
3440}
3441static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_bpt_pause_report_f(void)
3442{
3443 return 0x20;
3444}
3445static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_report_mask_single_step_complete_report_f(void)
3446{
3447 return 0x40;
3448}
3449static inline u32 gr_gpcs_tpcs_tpccs_tpc_exception_en_r(void)
3450{
3451 return 0x00419d0c;
3452}
3453static inline u32 gr_gpcs_tpcs_tpccs_tpc_exception_en_sm_enabled_f(void)
3454{
3455 return 0x2;
3456}
3457static inline u32 gr_gpcs_tpcs_tpccs_tpc_exception_en_tex_enabled_f(void)
3458{
3459 return 0x1;
3460}
3461static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_en_r(void)
3462{
3463 return 0x0050450c;
3464}
3465static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_en_sm_v(u32 r)
3466{
3467 return (r >> 1) & 0x1;
3468}
3469static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_en_sm_enabled_f(void)
3470{
3471 return 0x2;
3472}
3473static inline u32 gr_gpcs_gpccs_gpc_exception_en_r(void)
3474{
3475 return 0x0041ac94;
3476}
3477static inline u32 gr_gpcs_gpccs_gpc_exception_en_tpc_f(u32 v)
3478{
3479 return (v & 0xff) << 16;
3480}
3481static inline u32 gr_gpc0_gpccs_gpc_exception_r(void)
3482{
3483 return 0x00502c90;
3484}
3485static inline u32 gr_gpc0_gpccs_gpc_exception_tpc_v(u32 r)
3486{
3487 return (r >> 16) & 0xff;
3488}
3489static inline u32 gr_gpc0_gpccs_gpc_exception_tpc_0_pending_v(void)
3490{
3491 return 0x00000001;
3492}
3493static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_r(void)
3494{
3495 return 0x00504508;
3496}
3497static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_tex_v(u32 r)
3498{
3499 return (r >> 0) & 0x1;
3500}
3501static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_tex_pending_v(void)
3502{
3503 return 0x00000001;
3504}
3505static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_sm_v(u32 r)
3506{
3507 return (r >> 1) & 0x1;
3508}
3509static inline u32 gr_gpc0_tpc0_tpccs_tpc_exception_sm_pending_v(void)
3510{
3511 return 0x00000001;
3512}
3513static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_r(void)
3514{
3515 return 0x00504610;
3516}
3517static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_m(void)
3518{
3519 return 0x1 << 0;
3520}
3521static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_v(u32 r)
3522{
3523 return (r >> 0) & 0x1;
3524}
3525static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_on_v(void)
3526{
3527 return 0x00000001;
3528}
3529static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_debugger_mode_off_v(void)
3530{
3531 return 0x00000000;
3532}
3533static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_trigger_enable_f(void)
3534{
3535 return 0x80000000;
3536}
3537static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_trigger_disable_f(void)
3538{
3539 return 0x0;
3540}
3541static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_single_step_mode_enable_f(void)
3542{
3543 return 0x8;
3544}
3545static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_single_step_mode_disable_f(void)
3546{
3547 return 0x0;
3548}
3549static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_run_trigger_task_f(void)
3550{
3551 return 0x40000000;
3552}
3553static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_warp_m(void)
3554{
3555 return 0x1 << 1;
3556}
3557static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_warp_v(u32 r)
3558{
3559 return (r >> 1) & 0x1;
3560}
3561static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_warp_disable_f(void)
3562{
3563 return 0x0;
3564}
3565static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_sm_m(void)
3566{
3567 return 0x1 << 2;
3568}
3569static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_sm_v(u32 r)
3570{
3571 return (r >> 2) & 0x1;
3572}
3573static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_sm_disable_f(void)
3574{
3575 return 0x0;
3576}
3577static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_sm_stop_on_any_warp_disable_v(void)
3578{
3579 return 0x00000000;
3580}
3581static inline u32 gr_gpc0_tpc0_sm_dbgr_control0_stop_on_any_sm_stop_on_any_sm_disable_v(void)
3582{
3583 return 0x00000000;
3584}
3585static inline u32 gr_gpc0_tpc0_sm_warp_valid_mask_r(void)
3586{
3587 return 0x00504614;
3588}
3589static inline u32 gr_gpc0_tpc0_sm_dbgr_bpt_pause_mask_r(void)
3590{
3591 return 0x00504624;
3592}
3593static inline u32 gr_gpc0_tpc0_sm_dbgr_bpt_trap_mask_r(void)
3594{
3595 return 0x00504634;
3596}
3597static inline u32 gr_gpcs_tpcs_sm_dbgr_bpt_pause_mask_r(void)
3598{
3599 return 0x00419e24;
3600}
3601static inline u32 gr_gpc0_tpc0_sm_dbgr_status0_r(void)
3602{
3603 return 0x0050460c;
3604}
3605static inline u32 gr_gpc0_tpc0_sm_dbgr_status0_sm_in_trap_mode_v(u32 r)
3606{
3607 return (r >> 0) & 0x1;
3608}
3609static inline u32 gr_gpc0_tpc0_sm_dbgr_status0_locked_down_v(u32 r)
3610{
3611 return (r >> 4) & 0x1;
3612}
3613static inline u32 gr_gpc0_tpc0_sm_dbgr_status0_locked_down_true_v(void)
3614{
3615 return 0x00000001;
3616}
3617static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_r(void)
3618{
3619 return 0x00419e50;
3620}
3621static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_bpt_int_pending_f(void)
3622{
3623 return 0x10;
3624}
3625static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_bpt_pause_pending_f(void)
3626{
3627 return 0x20;
3628}
3629static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_single_step_complete_pending_f(void)
3630{
3631 return 0x40;
3632}
3633static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_sm_to_sm_fault_pending_f(void)
3634{
3635 return 0x1;
3636}
3637static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_l1_error_pending_f(void)
3638{
3639 return 0x2;
3640}
3641static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_multiple_warp_errors_pending_f(void)
3642{
3643 return 0x4;
3644}
3645static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_physical_stack_overflow_error_pending_f(void)
3646{
3647 return 0x8;
3648}
3649static inline u32 gr_gpcs_tpcs_sm_hww_global_esr_timeout_error_pending_f(void)
3650{
3651 return 0x80000000;
3652}
3653static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_r(void)
3654{
3655 return 0x00504650;
3656}
3657static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_bpt_int_pending_f(void)
3658{
3659 return 0x10;
3660}
3661static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_ecc_sec_error_pending_f(void)
3662{
3663 return 0x20000000;
3664}
3665static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_ecc_ded_error_pending_f(void)
3666{
3667 return 0x40000000;
3668}
3669static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_bpt_pause_pending_f(void)
3670{
3671 return 0x20;
3672}
3673static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_single_step_complete_pending_f(void)
3674{
3675 return 0x40;
3676}
3677static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_sm_to_sm_fault_pending_f(void)
3678{
3679 return 0x1;
3680}
3681static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_l1_error_pending_f(void)
3682{
3683 return 0x2;
3684}
3685static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_multiple_warp_errors_pending_f(void)
3686{
3687 return 0x4;
3688}
3689static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_physical_stack_overflow_error_pending_f(void)
3690{
3691 return 0x8;
3692}
3693static inline u32 gr_gpc0_tpc0_sm_hww_global_esr_timeout_error_pending_f(void)
3694{
3695 return 0x80000000;
3696}
3697static inline u32 gr_gpc0_tpc0_tex_m_hww_esr_r(void)
3698{
3699 return 0x00504224;
3700}
3701static inline u32 gr_gpc0_tpc0_tex_m_hww_esr_intr_pending_f(void)
3702{
3703 return 0x1;
3704}
3705static inline u32 gr_gpc0_tpc0_tex_m_hww_esr_ecc_sec_pending_f(void)
3706{
3707 return 0x80;
3708}
3709static inline u32 gr_gpc0_tpc0_tex_m_hww_esr_ecc_ded_pending_f(void)
3710{
3711 return 0x100;
3712}
3713static inline u32 gr_gpc0_tpc0_tex_m_hww_esr_reset_active_f(void)
3714{
3715 return 0x40000000;
3716}
3717static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_r(void)
3718{
3719 return 0x00504648;
3720}
3721static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_error_v(u32 r)
3722{
3723 return (r >> 0) & 0xffff;
3724}
3725static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_error_none_v(void)
3726{
3727 return 0x00000000;
3728}
3729static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_error_none_f(void)
3730{
3731 return 0x0;
3732}
3733static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_addr_valid_m(void)
3734{
3735 return 0x1 << 24;
3736}
3737static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_addr_error_type_m(void)
3738{
3739 return 0x7 << 25;
3740}
3741static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_addr_error_type_none_f(void)
3742{
3743 return 0x0;
3744}
3745static inline u32 gr_gpc0_tpc0_sm_hww_warp_esr_pc_r(void)
3746{
3747 return 0x00504654;
3748}
3749static inline u32 gr_gpc0_tpc0_sm_halfctl_ctrl_r(void)
3750{
3751 return 0x00504770;
3752}
3753static inline u32 gr_gpcs_tpcs_sm_halfctl_ctrl_r(void)
3754{
3755 return 0x00419f70;
3756}
3757static inline u32 gr_gpcs_tpcs_sm_halfctl_ctrl_sctl_read_quad_ctl_m(void)
3758{
3759 return 0x1 << 4;
3760}
3761static inline u32 gr_gpcs_tpcs_sm_halfctl_ctrl_sctl_read_quad_ctl_f(u32 v)
3762{
3763 return (v & 0x1) << 4;
3764}
3765static inline u32 gr_gpc0_tpc0_sm_debug_sfe_control_r(void)
3766{
3767 return 0x0050477c;
3768}
3769static inline u32 gr_gpcs_tpcs_sm_debug_sfe_control_r(void)
3770{
3771 return 0x00419f7c;
3772}
3773static inline u32 gr_gpcs_tpcs_sm_debug_sfe_control_read_half_ctl_m(void)
3774{
3775 return 0x1 << 0;
3776}
3777static inline u32 gr_gpcs_tpcs_sm_debug_sfe_control_read_half_ctl_f(u32 v)
3778{
3779 return (v & 0x1) << 0;
3780}
3781static inline u32 gr_gpcs_tpcs_pes_vsc_vpc_r(void)
3782{
3783 return 0x0041be08;
3784}
3785static inline u32 gr_gpcs_tpcs_pes_vsc_vpc_fast_mode_switch_true_f(void)
3786{
3787 return 0x4;
3788}
3789static inline u32 gr_ppcs_wwdx_map_gpc_map0_r(void)
3790{
3791 return 0x0041bf00;
3792}
3793static inline u32 gr_ppcs_wwdx_map_gpc_map1_r(void)
3794{
3795 return 0x0041bf04;
3796}
3797static inline u32 gr_ppcs_wwdx_map_gpc_map2_r(void)
3798{
3799 return 0x0041bf08;
3800}
3801static inline u32 gr_ppcs_wwdx_map_gpc_map3_r(void)
3802{
3803 return 0x0041bf0c;
3804}
3805static inline u32 gr_ppcs_wwdx_map_gpc_map4_r(void)
3806{
3807 return 0x0041bf10;
3808}
3809static inline u32 gr_ppcs_wwdx_map_gpc_map5_r(void)
3810{
3811 return 0x0041bf14;
3812}
3813static inline u32 gr_ppcs_wwdx_map_table_cfg_r(void)
3814{
3815 return 0x0041bfd0;
3816}
3817static inline u32 gr_ppcs_wwdx_map_table_cfg_row_offset_f(u32 v)
3818{
3819 return (v & 0xff) << 0;
3820}
3821static inline u32 gr_ppcs_wwdx_map_table_cfg_num_entries_f(u32 v)
3822{
3823 return (v & 0xff) << 8;
3824}
3825static inline u32 gr_ppcs_wwdx_map_table_cfg_normalized_num_entries_f(u32 v)
3826{
3827 return (v & 0x1f) << 16;
3828}
3829static inline u32 gr_ppcs_wwdx_map_table_cfg_normalized_shift_value_f(u32 v)
3830{
3831 return (v & 0x7) << 21;
3832}
3833static inline u32 gr_ppcs_wwdx_map_table_cfg_coeff5_mod_value_f(u32 v)
3834{
3835 return (v & 0x1f) << 24;
3836}
3837static inline u32 gr_gpcs_ppcs_wwdx_sm_num_rcp_r(void)
3838{
3839 return 0x0041bfd4;
3840}
3841static inline u32 gr_gpcs_ppcs_wwdx_sm_num_rcp_conservative_f(u32 v)
3842{
3843 return (v & 0xffffff) << 0;
3844}
3845static inline u32 gr_ppcs_wwdx_map_table_cfg2_r(void)
3846{
3847 return 0x0041bfe4;
3848}
3849static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff6_mod_value_f(u32 v)
3850{
3851 return (v & 0x1f) << 0;
3852}
3853static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff7_mod_value_f(u32 v)
3854{
3855 return (v & 0x1f) << 5;
3856}
3857static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff8_mod_value_f(u32 v)
3858{
3859 return (v & 0x1f) << 10;
3860}
3861static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff9_mod_value_f(u32 v)
3862{
3863 return (v & 0x1f) << 15;
3864}
3865static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff10_mod_value_f(u32 v)
3866{
3867 return (v & 0x1f) << 20;
3868}
3869static inline u32 gr_ppcs_wwdx_map_table_cfg2_coeff11_mod_value_f(u32 v)
3870{
3871 return (v & 0x1f) << 25;
3872}
3873static inline u32 gr_bes_zrop_settings_r(void)
3874{
3875 return 0x00408850;
3876}
3877static inline u32 gr_bes_zrop_settings_num_active_ltcs_f(u32 v)
3878{
3879 return (v & 0xf) << 0;
3880}
3881static inline u32 gr_be0_crop_debug3_r(void)
3882{
3883 return 0x00410108;
3884}
3885static inline u32 gr_bes_crop_debug3_r(void)
3886{
3887 return 0x00408908;
3888}
3889static inline u32 gr_bes_crop_debug3_comp_vdc_4to2_disable_m(void)
3890{
3891 return 0x1 << 31;
3892}
3893static inline u32 gr_bes_crop_settings_r(void)
3894{
3895 return 0x00408958;
3896}
3897static inline u32 gr_bes_crop_settings_num_active_ltcs_f(u32 v)
3898{
3899 return (v & 0xf) << 0;
3900}
3901static inline u32 gr_zcull_bytes_per_aliquot_per_gpu_v(void)
3902{
3903 return 0x00000020;
3904}
3905static inline u32 gr_zcull_save_restore_header_bytes_per_gpc_v(void)
3906{
3907 return 0x00000020;
3908}
3909static inline u32 gr_zcull_save_restore_subregion_header_bytes_per_gpc_v(void)
3910{
3911 return 0x000000c0;
3912}
3913static inline u32 gr_zcull_subregion_qty_v(void)
3914{
3915 return 0x00000010;
3916}
3917static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control_sel0_r(void)
3918{
3919 return 0x00504604;
3920}
3921static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control_sel1_r(void)
3922{
3923 return 0x00504608;
3924}
3925static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control0_r(void)
3926{
3927 return 0x0050465c;
3928}
3929static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control1_r(void)
3930{
3931 return 0x00504660;
3932}
3933static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control2_r(void)
3934{
3935 return 0x00504664;
3936}
3937static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control3_r(void)
3938{
3939 return 0x00504668;
3940}
3941static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control4_r(void)
3942{
3943 return 0x0050466c;
3944}
3945static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_control5_r(void)
3946{
3947 return 0x00504658;
3948}
3949static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter0_control_r(void)
3950{
3951 return 0x00504730;
3952}
3953static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter1_control_r(void)
3954{
3955 return 0x00504734;
3956}
3957static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter2_control_r(void)
3958{
3959 return 0x00504738;
3960}
3961static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter3_control_r(void)
3962{
3963 return 0x0050473c;
3964}
3965static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter4_control_r(void)
3966{
3967 return 0x00504740;
3968}
3969static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter5_control_r(void)
3970{
3971 return 0x00504744;
3972}
3973static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter6_control_r(void)
3974{
3975 return 0x00504748;
3976}
3977static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter7_control_r(void)
3978{
3979 return 0x0050474c;
3980}
3981static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_status_s1_r(void)
3982{
3983 return 0x00504678;
3984}
3985static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter_status1_r(void)
3986{
3987 return 0x00504694;
3988}
3989static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter0_s0_r(void)
3990{
3991 return 0x005046f0;
3992}
3993static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter0_s1_r(void)
3994{
3995 return 0x00504700;
3996}
3997static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter1_s0_r(void)
3998{
3999 return 0x005046f4;
4000}
4001static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter1_s1_r(void)
4002{
4003 return 0x00504704;
4004}
4005static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter2_s0_r(void)
4006{
4007 return 0x005046f8;
4008}
4009static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter2_s1_r(void)
4010{
4011 return 0x00504708;
4012}
4013static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter3_s0_r(void)
4014{
4015 return 0x005046fc;
4016}
4017static inline u32 gr_pri_gpc0_tpc0_sm_dsm_perf_counter3_s1_r(void)
4018{
4019 return 0x0050470c;
4020}
4021static inline u32 gr_fe_pwr_mode_r(void)
4022{
4023 return 0x00404170;
4024}
4025static inline u32 gr_fe_pwr_mode_mode_auto_f(void)
4026{
4027 return 0x0;
4028}
4029static inline u32 gr_fe_pwr_mode_mode_force_on_f(void)
4030{
4031 return 0x2;
4032}
4033static inline u32 gr_fe_pwr_mode_req_v(u32 r)
4034{
4035 return (r >> 4) & 0x1;
4036}
4037static inline u32 gr_fe_pwr_mode_req_send_f(void)
4038{
4039 return 0x10;
4040}
4041static inline u32 gr_fe_pwr_mode_req_done_v(void)
4042{
4043 return 0x00000000;
4044}
4045static inline u32 gr_gpcs_pri_mmu_ctrl_r(void)
4046{
4047 return 0x00418880;
4048}
4049static inline u32 gr_gpcs_pri_mmu_ctrl_vm_pg_size_m(void)
4050{
4051 return 0x1 << 0;
4052}
4053static inline u32 gr_gpcs_pri_mmu_ctrl_use_pdb_big_page_size_m(void)
4054{
4055 return 0x1 << 11;
4056}
4057static inline u32 gr_gpcs_pri_mmu_ctrl_vol_fault_m(void)
4058{
4059 return 0x1 << 1;
4060}
4061static inline u32 gr_gpcs_pri_mmu_ctrl_comp_fault_m(void)
4062{
4063 return 0x1 << 2;
4064}
4065static inline u32 gr_gpcs_pri_mmu_ctrl_miss_gran_m(void)
4066{
4067 return 0x3 << 3;
4068}
4069static inline u32 gr_gpcs_pri_mmu_ctrl_cache_mode_m(void)
4070{
4071 return 0x3 << 5;
4072}
4073static inline u32 gr_gpcs_pri_mmu_ctrl_mmu_aperture_m(void)
4074{
4075 return 0x3 << 28;
4076}
4077static inline u32 gr_gpcs_pri_mmu_ctrl_mmu_vol_m(void)
4078{
4079 return 0x1 << 30;
4080}
4081static inline u32 gr_gpcs_pri_mmu_ctrl_mmu_disable_m(void)
4082{
4083 return 0x1 << 31;
4084}
4085static inline u32 gr_gpcs_pri_mmu_pm_unit_mask_r(void)
4086{
4087 return 0x00418890;
4088}
4089static inline u32 gr_gpcs_pri_mmu_pm_req_mask_r(void)
4090{
4091 return 0x00418894;
4092}
4093static inline u32 gr_gpcs_pri_mmu_debug_ctrl_r(void)
4094{
4095 return 0x004188b0;
4096}
4097static inline u32 gr_gpcs_pri_mmu_debug_ctrl_debug_v(u32 r)
4098{
4099 return (r >> 16) & 0x1;
4100}
4101static inline u32 gr_gpcs_pri_mmu_debug_ctrl_debug_enabled_v(void)
4102{
4103 return 0x00000001;
4104}
4105static inline u32 gr_gpcs_pri_mmu_debug_wr_r(void)
4106{
4107 return 0x004188b4;
4108}
4109static inline u32 gr_gpcs_pri_mmu_debug_rd_r(void)
4110{
4111 return 0x004188b8;
4112}
4113static inline u32 gr_gpcs_mmu_num_active_ltcs_r(void)
4114{
4115 return 0x004188ac;
4116}
4117static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_r(void)
4118{
4119 return 0x00419e10;
4120}
4121static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_debugger_mode_f(u32 v)
4122{
4123 return (v & 0x1) << 0;
4124}
4125static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_debugger_mode_on_v(void)
4126{
4127 return 0x00000001;
4128}
4129static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_stop_trigger_m(void)
4130{
4131 return 0x1 << 31;
4132}
4133static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_stop_trigger_v(u32 r)
4134{
4135 return (r >> 31) & 0x1;
4136}
4137static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_stop_trigger_enable_f(void)
4138{
4139 return 0x80000000;
4140}
4141static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_stop_trigger_disable_f(void)
4142{
4143 return 0x0;
4144}
4145static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_single_step_mode_m(void)
4146{
4147 return 0x1 << 3;
4148}
4149static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_single_step_mode_enable_f(void)
4150{
4151 return 0x8;
4152}
4153static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_single_step_mode_disable_f(void)
4154{
4155 return 0x0;
4156}
4157static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_run_trigger_m(void)
4158{
4159 return 0x1 << 30;
4160}
4161static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_run_trigger_v(u32 r)
4162{
4163 return (r >> 30) & 0x1;
4164}
4165static inline u32 gr_gpcs_tpcs_sm_dbgr_control0_run_trigger_task_f(void)
4166{
4167 return 0x40000000;
4168}
4169static inline u32 gr_fe_gfxp_wfi_timeout_r(void)
4170{
4171 return 0x004041c0;
4172}
4173static inline u32 gr_fe_gfxp_wfi_timeout_count_f(u32 v)
4174{
4175 return (v & 0xffffffff) << 0;
4176}
4177static inline u32 gr_fe_gfxp_wfi_timeout_count_disabled_f(void)
4178{
4179 return 0x0;
4180}
4181static inline u32 gr_debug_2_r(void)
4182{
4183 return 0x00400088;
4184}
4185static inline u32 gr_debug_2_gfxp_wfi_always_injects_wfi_m(void)
4186{
4187 return 0x1 << 23;
4188}
4189static inline u32 gr_debug_2_gfxp_wfi_always_injects_wfi_v(u32 r)
4190{
4191 return (r >> 23) & 0x1;
4192}
4193static inline u32 gr_debug_2_gfxp_wfi_always_injects_wfi_enabled_f(void)
4194{
4195 return 0x800000;
4196}
4197static inline u32 gr_debug_2_gfxp_wfi_always_injects_wfi_disabled_f(void)
4198{
4199 return 0x0;
4200}
4201static inline u32 gr_gpcs_tpcs_sm_texio_control_r(void)
4202{
4203 return 0x00419c84;
4204}
4205static inline u32 gr_gpcs_tpcs_sm_texio_control_oor_addr_check_mode_f(u32 v)
4206{
4207 return (v & 0x7) << 8;
4208}
4209static inline u32 gr_gpcs_tpcs_sm_texio_control_oor_addr_check_mode_m(void)
4210{
4211 return 0x7 << 8;
4212}
4213static inline u32 gr_gpcs_tpcs_sm_texio_control_oor_addr_check_mode_arm_63_48_match_f(void)
4214{
4215 return 0x100;
4216}
4217static inline u32 gr_gpcs_tpcs_sm_disp_ctrl_r(void)
4218{
4219 return 0x00419f78;
4220}
4221static inline u32 gr_gpcs_tpcs_sm_disp_ctrl_re_suppress_m(void)
4222{
4223 return 0x3 << 11;
4224}
4225static inline u32 gr_gpcs_tpcs_sm_disp_ctrl_re_suppress_disable_f(void)
4226{
4227 return 0x1000;
4228}
4229static inline u32 gr_gpcs_tc_debug0_r(void)
4230{
4231 return 0x00418708;
4232}
4233static inline u32 gr_gpcs_tc_debug0_limit_coalesce_buffer_size_f(u32 v)
4234{
4235 return (v & 0xff) << 0;
4236}
4237static inline u32 gr_gpcs_tc_debug0_limit_coalesce_buffer_size_m(void)
4238{
4239 return 0xff << 0;
4240}
4241#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_ltc_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_ltc_gp10b.h
new file mode 100644
index 00000000..4a3f634e
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_ltc_gp10b.h
@@ -0,0 +1,581 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ltc_gp10b_h_
51#define _hw_ltc_gp10b_h_
52
53static inline u32 ltc_pltcg_base_v(void)
54{
55 return 0x00140000;
56}
57static inline u32 ltc_pltcg_extent_v(void)
58{
59 return 0x0017ffff;
60}
61static inline u32 ltc_ltc0_ltss_v(void)
62{
63 return 0x00140200;
64}
65static inline u32 ltc_ltc0_lts0_v(void)
66{
67 return 0x00140400;
68}
69static inline u32 ltc_ltcs_ltss_v(void)
70{
71 return 0x0017e200;
72}
73static inline u32 ltc_ltcs_lts0_cbc_ctrl1_r(void)
74{
75 return 0x0014046c;
76}
77static inline u32 ltc_ltc0_lts0_dstg_cfg0_r(void)
78{
79 return 0x00140518;
80}
81static inline u32 ltc_ltcs_ltss_dstg_cfg0_r(void)
82{
83 return 0x0017e318;
84}
85static inline u32 ltc_ltcs_ltss_dstg_cfg0_vdc_4to2_disable_m(void)
86{
87 return 0x1 << 15;
88}
89static inline u32 ltc_ltc0_lts0_tstg_cfg1_r(void)
90{
91 return 0x00140494;
92}
93static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_ways_v(u32 r)
94{
95 return (r >> 0) & 0xffff;
96}
97static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_sets_v(u32 r)
98{
99 return (r >> 16) & 0x3;
100}
101static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_sets_all_v(void)
102{
103 return 0x00000000;
104}
105static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_sets_half_v(void)
106{
107 return 0x00000001;
108}
109static inline u32 ltc_ltc0_lts0_tstg_cfg1_active_sets_quarter_v(void)
110{
111 return 0x00000002;
112}
113static inline u32 ltc_ltcs_ltss_cbc_ctrl1_r(void)
114{
115 return 0x0017e26c;
116}
117static inline u32 ltc_ltcs_ltss_cbc_ctrl1_clean_active_f(void)
118{
119 return 0x1;
120}
121static inline u32 ltc_ltcs_ltss_cbc_ctrl1_invalidate_active_f(void)
122{
123 return 0x2;
124}
125static inline u32 ltc_ltcs_ltss_cbc_ctrl1_clear_v(u32 r)
126{
127 return (r >> 2) & 0x1;
128}
129static inline u32 ltc_ltcs_ltss_cbc_ctrl1_clear_active_v(void)
130{
131 return 0x00000001;
132}
133static inline u32 ltc_ltcs_ltss_cbc_ctrl1_clear_active_f(void)
134{
135 return 0x4;
136}
137static inline u32 ltc_ltc0_lts0_cbc_ctrl1_r(void)
138{
139 return 0x0014046c;
140}
141static inline u32 ltc_ltcs_ltss_cbc_ctrl2_r(void)
142{
143 return 0x0017e270;
144}
145static inline u32 ltc_ltcs_ltss_cbc_ctrl2_clear_lower_bound_f(u32 v)
146{
147 return (v & 0x3ffff) << 0;
148}
149static inline u32 ltc_ltcs_ltss_cbc_ctrl3_r(void)
150{
151 return 0x0017e274;
152}
153static inline u32 ltc_ltcs_ltss_cbc_ctrl3_clear_upper_bound_f(u32 v)
154{
155 return (v & 0x3ffff) << 0;
156}
157static inline u32 ltc_ltcs_ltss_cbc_ctrl3_clear_upper_bound_init_v(void)
158{
159 return 0x0003ffff;
160}
161static inline u32 ltc_ltcs_ltss_cbc_base_r(void)
162{
163 return 0x0017e278;
164}
165static inline u32 ltc_ltcs_ltss_cbc_base_alignment_shift_v(void)
166{
167 return 0x0000000b;
168}
169static inline u32 ltc_ltcs_ltss_cbc_base_address_v(u32 r)
170{
171 return (r >> 0) & 0x3ffffff;
172}
173static inline u32 ltc_ltcs_ltss_cbc_num_active_ltcs_r(void)
174{
175 return 0x0017e27c;
176}
177static inline u32 ltc_ltcs_misc_ltc_num_active_ltcs_r(void)
178{
179 return 0x0017e000;
180}
181static inline u32 ltc_ltcs_ltss_cbc_param_r(void)
182{
183 return 0x0017e280;
184}
185static inline u32 ltc_ltcs_ltss_cbc_param_comptags_per_cache_line_v(u32 r)
186{
187 return (r >> 0) & 0xffff;
188}
189static inline u32 ltc_ltcs_ltss_cbc_param_cache_line_size_v(u32 r)
190{
191 return (r >> 24) & 0xf;
192}
193static inline u32 ltc_ltcs_ltss_cbc_param_slices_per_ltc_v(u32 r)
194{
195 return (r >> 28) & 0xf;
196}
197static inline u32 ltc_ltcs_ltss_cbc_param2_r(void)
198{
199 return 0x0017e3f4;
200}
201static inline u32 ltc_ltcs_ltss_cbc_param2_gobs_per_comptagline_per_slice_v(u32 r)
202{
203 return (r >> 0) & 0xffff;
204}
205static inline u32 ltc_ltcs_ltss_tstg_set_mgmt_r(void)
206{
207 return 0x0017e2ac;
208}
209static inline u32 ltc_ltcs_ltss_tstg_set_mgmt_max_ways_evict_last_f(u32 v)
210{
211 return (v & 0x1f) << 16;
212}
213static inline u32 ltc_ltcs_ltss_dstg_zbc_index_r(void)
214{
215 return 0x0017e338;
216}
217static inline u32 ltc_ltcs_ltss_dstg_zbc_index_address_f(u32 v)
218{
219 return (v & 0xf) << 0;
220}
221static inline u32 ltc_ltcs_ltss_dstg_zbc_color_clear_value_r(u32 i)
222{
223 return 0x0017e33c + i*4;
224}
225static inline u32 ltc_ltcs_ltss_dstg_zbc_color_clear_value__size_1_v(void)
226{
227 return 0x00000004;
228}
229static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_r(void)
230{
231 return 0x0017e34c;
232}
233static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_field_s(void)
234{
235 return 32;
236}
237static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_field_f(u32 v)
238{
239 return (v & 0xffffffff) << 0;
240}
241static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_field_m(void)
242{
243 return 0xffffffff << 0;
244}
245static inline u32 ltc_ltcs_ltss_dstg_zbc_depth_clear_value_field_v(u32 r)
246{
247 return (r >> 0) & 0xffffffff;
248}
249static inline u32 ltc_ltcs_ltss_tstg_set_mgmt_2_r(void)
250{
251 return 0x0017e2b0;
252}
253static inline u32 ltc_ltcs_ltss_tstg_set_mgmt_2_l2_bypass_mode_enabled_f(void)
254{
255 return 0x10000000;
256}
257static inline u32 ltc_ltcs_ltss_g_elpg_r(void)
258{
259 return 0x0017e214;
260}
261static inline u32 ltc_ltcs_ltss_g_elpg_flush_v(u32 r)
262{
263 return (r >> 0) & 0x1;
264}
265static inline u32 ltc_ltcs_ltss_g_elpg_flush_pending_v(void)
266{
267 return 0x00000001;
268}
269static inline u32 ltc_ltcs_ltss_g_elpg_flush_pending_f(void)
270{
271 return 0x1;
272}
273static inline u32 ltc_ltc0_ltss_g_elpg_r(void)
274{
275 return 0x00140214;
276}
277static inline u32 ltc_ltc0_ltss_g_elpg_flush_v(u32 r)
278{
279 return (r >> 0) & 0x1;
280}
281static inline u32 ltc_ltc0_ltss_g_elpg_flush_pending_v(void)
282{
283 return 0x00000001;
284}
285static inline u32 ltc_ltc0_ltss_g_elpg_flush_pending_f(void)
286{
287 return 0x1;
288}
289static inline u32 ltc_ltc1_ltss_g_elpg_r(void)
290{
291 return 0x00142214;
292}
293static inline u32 ltc_ltc1_ltss_g_elpg_flush_v(u32 r)
294{
295 return (r >> 0) & 0x1;
296}
297static inline u32 ltc_ltc1_ltss_g_elpg_flush_pending_v(void)
298{
299 return 0x00000001;
300}
301static inline u32 ltc_ltc1_ltss_g_elpg_flush_pending_f(void)
302{
303 return 0x1;
304}
305static inline u32 ltc_ltcs_ltss_intr_r(void)
306{
307 return 0x0017e20c;
308}
309static inline u32 ltc_ltcs_ltss_intr_ecc_sec_error_pending_f(void)
310{
311 return 0x100;
312}
313static inline u32 ltc_ltcs_ltss_intr_ecc_ded_error_pending_f(void)
314{
315 return 0x200;
316}
317static inline u32 ltc_ltcs_ltss_intr_en_evicted_cb_m(void)
318{
319 return 0x1 << 20;
320}
321static inline u32 ltc_ltcs_ltss_intr_en_illegal_compstat_access_m(void)
322{
323 return 0x1 << 30;
324}
325static inline u32 ltc_ltcs_ltss_intr_en_ecc_sec_error_enabled_f(void)
326{
327 return 0x1000000;
328}
329static inline u32 ltc_ltcs_ltss_intr_en_ecc_ded_error_enabled_f(void)
330{
331 return 0x2000000;
332}
333static inline u32 ltc_ltc0_lts0_intr_r(void)
334{
335 return 0x0014040c;
336}
337static inline u32 ltc_ltc0_lts0_dstg_ecc_report_r(void)
338{
339 return 0x0014051c;
340}
341static inline u32 ltc_ltc0_lts0_dstg_ecc_report_sec_count_m(void)
342{
343 return 0xff << 0;
344}
345static inline u32 ltc_ltc0_lts0_dstg_ecc_report_sec_count_v(u32 r)
346{
347 return (r >> 0) & 0xff;
348}
349static inline u32 ltc_ltc0_lts0_dstg_ecc_report_ded_count_m(void)
350{
351 return 0xff << 16;
352}
353static inline u32 ltc_ltc0_lts0_dstg_ecc_report_ded_count_v(u32 r)
354{
355 return (r >> 16) & 0xff;
356}
357static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_r(void)
358{
359 return 0x0017e2a0;
360}
361static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_v(u32 r)
362{
363 return (r >> 0) & 0x1;
364}
365static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_pending_v(void)
366{
367 return 0x00000001;
368}
369static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_pending_f(void)
370{
371 return 0x1;
372}
373static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_max_cycles_between_invalidates_v(u32 r)
374{
375 return (r >> 8) & 0xf;
376}
377static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_max_cycles_between_invalidates_3_v(void)
378{
379 return 0x00000003;
380}
381static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_max_cycles_between_invalidates_3_f(void)
382{
383 return 0x300;
384}
385static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_last_class_v(u32 r)
386{
387 return (r >> 28) & 0x1;
388}
389static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_last_class_true_v(void)
390{
391 return 0x00000001;
392}
393static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_last_class_true_f(void)
394{
395 return 0x10000000;
396}
397static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_normal_class_v(u32 r)
398{
399 return (r >> 29) & 0x1;
400}
401static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_normal_class_true_v(void)
402{
403 return 0x00000001;
404}
405static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_normal_class_true_f(void)
406{
407 return 0x20000000;
408}
409static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_first_class_v(u32 r)
410{
411 return (r >> 30) & 0x1;
412}
413static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_first_class_true_v(void)
414{
415 return 0x00000001;
416}
417static inline u32 ltc_ltcs_ltss_tstg_cmgmt0_invalidate_evict_first_class_true_f(void)
418{
419 return 0x40000000;
420}
421static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_r(void)
422{
423 return 0x0017e2a4;
424}
425static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_v(u32 r)
426{
427 return (r >> 0) & 0x1;
428}
429static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_pending_v(void)
430{
431 return 0x00000001;
432}
433static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_pending_f(void)
434{
435 return 0x1;
436}
437static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_max_cycles_between_cleans_v(u32 r)
438{
439 return (r >> 8) & 0xf;
440}
441static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_max_cycles_between_cleans_3_v(void)
442{
443 return 0x00000003;
444}
445static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_max_cycles_between_cleans_3_f(void)
446{
447 return 0x300;
448}
449static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_wait_for_fb_to_pull_v(u32 r)
450{
451 return (r >> 16) & 0x1;
452}
453static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_wait_for_fb_to_pull_true_v(void)
454{
455 return 0x00000001;
456}
457static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_wait_for_fb_to_pull_true_f(void)
458{
459 return 0x10000;
460}
461static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_last_class_v(u32 r)
462{
463 return (r >> 28) & 0x1;
464}
465static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_last_class_true_v(void)
466{
467 return 0x00000001;
468}
469static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_last_class_true_f(void)
470{
471 return 0x10000000;
472}
473static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_normal_class_v(u32 r)
474{
475 return (r >> 29) & 0x1;
476}
477static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_normal_class_true_v(void)
478{
479 return 0x00000001;
480}
481static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_normal_class_true_f(void)
482{
483 return 0x20000000;
484}
485static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_first_class_v(u32 r)
486{
487 return (r >> 30) & 0x1;
488}
489static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_first_class_true_v(void)
490{
491 return 0x00000001;
492}
493static inline u32 ltc_ltcs_ltss_tstg_cmgmt1_clean_evict_first_class_true_f(void)
494{
495 return 0x40000000;
496}
497static inline u32 ltc_ltc0_ltss_tstg_cmgmt0_r(void)
498{
499 return 0x001402a0;
500}
501static inline u32 ltc_ltc0_ltss_tstg_cmgmt0_invalidate_v(u32 r)
502{
503 return (r >> 0) & 0x1;
504}
505static inline u32 ltc_ltc0_ltss_tstg_cmgmt0_invalidate_pending_v(void)
506{
507 return 0x00000001;
508}
509static inline u32 ltc_ltc0_ltss_tstg_cmgmt0_invalidate_pending_f(void)
510{
511 return 0x1;
512}
513static inline u32 ltc_ltc0_ltss_tstg_cmgmt1_r(void)
514{
515 return 0x001402a4;
516}
517static inline u32 ltc_ltc0_ltss_tstg_cmgmt1_clean_v(u32 r)
518{
519 return (r >> 0) & 0x1;
520}
521static inline u32 ltc_ltc0_ltss_tstg_cmgmt1_clean_pending_v(void)
522{
523 return 0x00000001;
524}
525static inline u32 ltc_ltc0_ltss_tstg_cmgmt1_clean_pending_f(void)
526{
527 return 0x1;
528}
529static inline u32 ltc_ltc1_ltss_tstg_cmgmt0_r(void)
530{
531 return 0x001422a0;
532}
533static inline u32 ltc_ltc1_ltss_tstg_cmgmt0_invalidate_v(u32 r)
534{
535 return (r >> 0) & 0x1;
536}
537static inline u32 ltc_ltc1_ltss_tstg_cmgmt0_invalidate_pending_v(void)
538{
539 return 0x00000001;
540}
541static inline u32 ltc_ltc1_ltss_tstg_cmgmt0_invalidate_pending_f(void)
542{
543 return 0x1;
544}
545static inline u32 ltc_ltc1_ltss_tstg_cmgmt1_r(void)
546{
547 return 0x001422a4;
548}
549static inline u32 ltc_ltc1_ltss_tstg_cmgmt1_clean_v(u32 r)
550{
551 return (r >> 0) & 0x1;
552}
553static inline u32 ltc_ltc1_ltss_tstg_cmgmt1_clean_pending_v(void)
554{
555 return 0x00000001;
556}
557static inline u32 ltc_ltc1_ltss_tstg_cmgmt1_clean_pending_f(void)
558{
559 return 0x1;
560}
561static inline u32 ltc_ltc0_lts0_tstg_info_1_r(void)
562{
563 return 0x0014058c;
564}
565static inline u32 ltc_ltc0_lts0_tstg_info_1_slice_size_in_kb_v(u32 r)
566{
567 return (r >> 0) & 0xffff;
568}
569static inline u32 ltc_ltc0_lts0_tstg_info_1_slices_per_l2_v(u32 r)
570{
571 return (r >> 16) & 0x1f;
572}
573static inline u32 ltc_ltca_g_axi_pctrl_r(void)
574{
575 return 0x00160000;
576}
577static inline u32 ltc_ltca_g_axi_pctrl_user_sid_f(u32 v)
578{
579 return (v & 0xff) << 2;
580}
581#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_mc_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_mc_gp10b.h
new file mode 100644
index 00000000..30165e66
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_mc_gp10b.h
@@ -0,0 +1,245 @@
1/*
2 * Copyright (c) 2014, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_mc_gp10b_h_
51#define _hw_mc_gp10b_h_
52
53static inline u32 mc_boot_0_r(void)
54{
55 return 0x00000000;
56}
57static inline u32 mc_boot_0_architecture_v(u32 r)
58{
59 return (r >> 24) & 0x1f;
60}
61static inline u32 mc_boot_0_implementation_v(u32 r)
62{
63 return (r >> 20) & 0xf;
64}
65static inline u32 mc_boot_0_major_revision_v(u32 r)
66{
67 return (r >> 4) & 0xf;
68}
69static inline u32 mc_boot_0_minor_revision_v(u32 r)
70{
71 return (r >> 0) & 0xf;
72}
73static inline u32 mc_intr_r(u32 i)
74{
75 return 0x00000100 + i*4;
76}
77static inline u32 mc_intr_pfifo_pending_f(void)
78{
79 return 0x100;
80}
81static inline u32 mc_intr_replayable_fault_pending_f(void)
82{
83 return 0x200;
84}
85static inline u32 mc_intr_pgraph_pending_f(void)
86{
87 return 0x1000;
88}
89static inline u32 mc_intr_pmu_pending_f(void)
90{
91 return 0x1000000;
92}
93static inline u32 mc_intr_ltc_pending_f(void)
94{
95 return 0x2000000;
96}
97static inline u32 mc_intr_priv_ring_pending_f(void)
98{
99 return 0x40000000;
100}
101static inline u32 mc_intr_pbus_pending_f(void)
102{
103 return 0x10000000;
104}
105static inline u32 mc_intr_en_r(u32 i)
106{
107 return 0x00000140 + i*4;
108}
109static inline u32 mc_intr_en_set_r(u32 i)
110{
111 return 0x00000160 + i*4;
112}
113static inline u32 mc_intr_en_clear_r(u32 i)
114{
115 return 0x00000180 + i*4;
116}
117static inline u32 mc_enable_r(void)
118{
119 return 0x00000200;
120}
121static inline u32 mc_enable_xbar_enabled_f(void)
122{
123 return 0x4;
124}
125static inline u32 mc_enable_l2_enabled_f(void)
126{
127 return 0x8;
128}
129static inline u32 mc_enable_pmedia_s(void)
130{
131 return 1;
132}
133static inline u32 mc_enable_pmedia_f(u32 v)
134{
135 return (v & 0x1) << 4;
136}
137static inline u32 mc_enable_pmedia_m(void)
138{
139 return 0x1 << 4;
140}
141static inline u32 mc_enable_pmedia_v(u32 r)
142{
143 return (r >> 4) & 0x1;
144}
145static inline u32 mc_enable_priv_ring_enabled_f(void)
146{
147 return 0x20;
148}
149static inline u32 mc_enable_ce0_m(void)
150{
151 return 0x1 << 6;
152}
153static inline u32 mc_enable_pfifo_enabled_f(void)
154{
155 return 0x100;
156}
157static inline u32 mc_enable_pgraph_enabled_f(void)
158{
159 return 0x1000;
160}
161static inline u32 mc_enable_pwr_v(u32 r)
162{
163 return (r >> 13) & 0x1;
164}
165static inline u32 mc_enable_pwr_disabled_v(void)
166{
167 return 0x00000000;
168}
169static inline u32 mc_enable_pwr_enabled_f(void)
170{
171 return 0x2000;
172}
173static inline u32 mc_enable_pfb_enabled_f(void)
174{
175 return 0x100000;
176}
177static inline u32 mc_enable_ce2_m(void)
178{
179 return 0x1 << 21;
180}
181static inline u32 mc_enable_ce2_enabled_f(void)
182{
183 return 0x200000;
184}
185static inline u32 mc_enable_blg_enabled_f(void)
186{
187 return 0x8000000;
188}
189static inline u32 mc_enable_perfmon_enabled_f(void)
190{
191 return 0x10000000;
192}
193static inline u32 mc_enable_hub_enabled_f(void)
194{
195 return 0x20000000;
196}
197static inline u32 mc_intr_ltc_r(void)
198{
199 return 0x000001c0;
200}
201static inline u32 mc_enable_pb_r(void)
202{
203 return 0x00000204;
204}
205static inline u32 mc_enable_pb_0_s(void)
206{
207 return 1;
208}
209static inline u32 mc_enable_pb_0_f(u32 v)
210{
211 return (v & 0x1) << 0;
212}
213static inline u32 mc_enable_pb_0_m(void)
214{
215 return 0x1 << 0;
216}
217static inline u32 mc_enable_pb_0_v(u32 r)
218{
219 return (r >> 0) & 0x1;
220}
221static inline u32 mc_enable_pb_0_enabled_v(void)
222{
223 return 0x00000001;
224}
225static inline u32 mc_enable_pb_sel_f(u32 v, u32 i)
226{
227 return (v & 0x1) << (0 + i*1);
228}
229static inline u32 mc_elpg_enable_r(void)
230{
231 return 0x0000020c;
232}
233static inline u32 mc_elpg_enable_xbar_enabled_f(void)
234{
235 return 0x4;
236}
237static inline u32 mc_elpg_enable_pfb_enabled_f(void)
238{
239 return 0x100000;
240}
241static inline u32 mc_elpg_enable_hub_enabled_f(void)
242{
243 return 0x20000000;
244}
245#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_pbdma_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_pbdma_gp10b.h
new file mode 100644
index 00000000..65aedccd
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_pbdma_gp10b.h
@@ -0,0 +1,593 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_pbdma_gp10b_h_
51#define _hw_pbdma_gp10b_h_
52
53static inline u32 pbdma_gp_entry1_r(void)
54{
55 return 0x10000004;
56}
57static inline u32 pbdma_gp_entry1_get_hi_v(u32 r)
58{
59 return (r >> 0) & 0xff;
60}
61static inline u32 pbdma_gp_entry1_length_f(u32 v)
62{
63 return (v & 0x1fffff) << 10;
64}
65static inline u32 pbdma_gp_entry1_length_v(u32 r)
66{
67 return (r >> 10) & 0x1fffff;
68}
69static inline u32 pbdma_gp_base_r(u32 i)
70{
71 return 0x00040048 + i*8192;
72}
73static inline u32 pbdma_gp_base__size_1_v(void)
74{
75 return 0x00000001;
76}
77static inline u32 pbdma_gp_base_offset_f(u32 v)
78{
79 return (v & 0x1fffffff) << 3;
80}
81static inline u32 pbdma_gp_base_rsvd_s(void)
82{
83 return 3;
84}
85static inline u32 pbdma_gp_base_hi_r(u32 i)
86{
87 return 0x0004004c + i*8192;
88}
89static inline u32 pbdma_gp_base_hi_offset_f(u32 v)
90{
91 return (v & 0xff) << 0;
92}
93static inline u32 pbdma_gp_base_hi_limit2_f(u32 v)
94{
95 return (v & 0x1f) << 16;
96}
97static inline u32 pbdma_gp_fetch_r(u32 i)
98{
99 return 0x00040050 + i*8192;
100}
101static inline u32 pbdma_gp_get_r(u32 i)
102{
103 return 0x00040014 + i*8192;
104}
105static inline u32 pbdma_gp_put_r(u32 i)
106{
107 return 0x00040000 + i*8192;
108}
109static inline u32 pbdma_pb_fetch_r(u32 i)
110{
111 return 0x00040054 + i*8192;
112}
113static inline u32 pbdma_pb_fetch_hi_r(u32 i)
114{
115 return 0x00040058 + i*8192;
116}
117static inline u32 pbdma_get_r(u32 i)
118{
119 return 0x00040018 + i*8192;
120}
121static inline u32 pbdma_get_hi_r(u32 i)
122{
123 return 0x0004001c + i*8192;
124}
125static inline u32 pbdma_put_r(u32 i)
126{
127 return 0x0004005c + i*8192;
128}
129static inline u32 pbdma_put_hi_r(u32 i)
130{
131 return 0x00040060 + i*8192;
132}
133static inline u32 pbdma_formats_r(u32 i)
134{
135 return 0x0004009c + i*8192;
136}
137static inline u32 pbdma_formats_gp_fermi0_f(void)
138{
139 return 0x0;
140}
141static inline u32 pbdma_formats_pb_fermi1_f(void)
142{
143 return 0x100;
144}
145static inline u32 pbdma_formats_mp_fermi0_f(void)
146{
147 return 0x0;
148}
149static inline u32 pbdma_pb_header_r(u32 i)
150{
151 return 0x00040084 + i*8192;
152}
153static inline u32 pbdma_pb_header_priv_user_f(void)
154{
155 return 0x0;
156}
157static inline u32 pbdma_pb_header_method_zero_f(void)
158{
159 return 0x0;
160}
161static inline u32 pbdma_pb_header_subchannel_zero_f(void)
162{
163 return 0x0;
164}
165static inline u32 pbdma_pb_header_level_main_f(void)
166{
167 return 0x0;
168}
169static inline u32 pbdma_pb_header_first_true_f(void)
170{
171 return 0x400000;
172}
173static inline u32 pbdma_pb_header_type_inc_f(void)
174{
175 return 0x20000000;
176}
177static inline u32 pbdma_pb_header_type_non_inc_f(void)
178{
179 return 0x60000000;
180}
181static inline u32 pbdma_hdr_shadow_r(u32 i)
182{
183 return 0x00040118 + i*8192;
184}
185static inline u32 pbdma_subdevice_r(u32 i)
186{
187 return 0x00040094 + i*8192;
188}
189static inline u32 pbdma_subdevice_id_f(u32 v)
190{
191 return (v & 0xfff) << 0;
192}
193static inline u32 pbdma_subdevice_status_active_f(void)
194{
195 return 0x10000000;
196}
197static inline u32 pbdma_subdevice_channel_dma_enable_f(void)
198{
199 return 0x20000000;
200}
201static inline u32 pbdma_method0_r(u32 i)
202{
203 return 0x000400c0 + i*8192;
204}
205static inline u32 pbdma_method0_fifo_size_v(void)
206{
207 return 0x00000004;
208}
209static inline u32 pbdma_method0_addr_f(u32 v)
210{
211 return (v & 0xfff) << 2;
212}
213static inline u32 pbdma_method0_addr_v(u32 r)
214{
215 return (r >> 2) & 0xfff;
216}
217static inline u32 pbdma_method0_subch_v(u32 r)
218{
219 return (r >> 16) & 0x7;
220}
221static inline u32 pbdma_method0_first_true_f(void)
222{
223 return 0x400000;
224}
225static inline u32 pbdma_method0_valid_true_f(void)
226{
227 return 0x80000000;
228}
229static inline u32 pbdma_method1_r(u32 i)
230{
231 return 0x000400c8 + i*8192;
232}
233static inline u32 pbdma_method2_r(u32 i)
234{
235 return 0x000400d0 + i*8192;
236}
237static inline u32 pbdma_method3_r(u32 i)
238{
239 return 0x000400d8 + i*8192;
240}
241static inline u32 pbdma_data0_r(u32 i)
242{
243 return 0x000400c4 + i*8192;
244}
245static inline u32 pbdma_target_r(u32 i)
246{
247 return 0x000400ac + i*8192;
248}
249static inline u32 pbdma_target_engine_sw_f(void)
250{
251 return 0x1f;
252}
253static inline u32 pbdma_acquire_r(u32 i)
254{
255 return 0x00040030 + i*8192;
256}
257static inline u32 pbdma_acquire_retry_man_2_f(void)
258{
259 return 0x2;
260}
261static inline u32 pbdma_acquire_retry_exp_2_f(void)
262{
263 return 0x100;
264}
265static inline u32 pbdma_acquire_timeout_exp_f(u32 v)
266{
267 return (v & 0xf) << 11;
268}
269static inline u32 pbdma_acquire_timeout_exp_max_v(void)
270{
271 return 0x0000000f;
272}
273static inline u32 pbdma_acquire_timeout_exp_max_f(void)
274{
275 return 0x7800;
276}
277static inline u32 pbdma_acquire_timeout_man_f(u32 v)
278{
279 return (v & 0xffff) << 15;
280}
281static inline u32 pbdma_acquire_timeout_man_max_v(void)
282{
283 return 0x0000ffff;
284}
285static inline u32 pbdma_acquire_timeout_man_max_f(void)
286{
287 return 0x7fff8000;
288}
289static inline u32 pbdma_acquire_timeout_en_enable_f(void)
290{
291 return 0x80000000;
292}
293static inline u32 pbdma_acquire_timeout_en_disable_f(void)
294{
295 return 0x0;
296}
297static inline u32 pbdma_status_r(u32 i)
298{
299 return 0x00040100 + i*8192;
300}
301static inline u32 pbdma_channel_r(u32 i)
302{
303 return 0x00040120 + i*8192;
304}
305static inline u32 pbdma_signature_r(u32 i)
306{
307 return 0x00040010 + i*8192;
308}
309static inline u32 pbdma_signature_hw_valid_f(void)
310{
311 return 0xface;
312}
313static inline u32 pbdma_signature_sw_zero_f(void)
314{
315 return 0x0;
316}
317static inline u32 pbdma_userd_r(u32 i)
318{
319 return 0x00040008 + i*8192;
320}
321static inline u32 pbdma_userd_target_vid_mem_f(void)
322{
323 return 0x0;
324}
325static inline u32 pbdma_userd_target_sys_mem_coh_f(void)
326{
327 return 0x2;
328}
329static inline u32 pbdma_userd_target_sys_mem_ncoh_f(void)
330{
331 return 0x3;
332}
333static inline u32 pbdma_userd_addr_f(u32 v)
334{
335 return (v & 0x7fffff) << 9;
336}
337static inline u32 pbdma_userd_hi_r(u32 i)
338{
339 return 0x0004000c + i*8192;
340}
341static inline u32 pbdma_userd_hi_addr_f(u32 v)
342{
343 return (v & 0xff) << 0;
344}
345static inline u32 pbdma_config_r(u32 i)
346{
347 return 0x000400f4 + i*8192;
348}
349static inline u32 pbdma_config_auth_level_privileged_f(void)
350{
351 return 0x100;
352}
353static inline u32 pbdma_hce_ctrl_r(u32 i)
354{
355 return 0x000400e4 + i*8192;
356}
357static inline u32 pbdma_hce_ctrl_hce_priv_mode_yes_f(void)
358{
359 return 0x20;
360}
361static inline u32 pbdma_intr_0_r(u32 i)
362{
363 return 0x00040108 + i*8192;
364}
365static inline u32 pbdma_intr_0_memreq_v(u32 r)
366{
367 return (r >> 0) & 0x1;
368}
369static inline u32 pbdma_intr_0_memreq_pending_f(void)
370{
371 return 0x1;
372}
373static inline u32 pbdma_intr_0_memack_timeout_pending_f(void)
374{
375 return 0x2;
376}
377static inline u32 pbdma_intr_0_memack_extra_pending_f(void)
378{
379 return 0x4;
380}
381static inline u32 pbdma_intr_0_memdat_timeout_pending_f(void)
382{
383 return 0x8;
384}
385static inline u32 pbdma_intr_0_memdat_extra_pending_f(void)
386{
387 return 0x10;
388}
389static inline u32 pbdma_intr_0_memflush_pending_f(void)
390{
391 return 0x20;
392}
393static inline u32 pbdma_intr_0_memop_pending_f(void)
394{
395 return 0x40;
396}
397static inline u32 pbdma_intr_0_lbconnect_pending_f(void)
398{
399 return 0x80;
400}
401static inline u32 pbdma_intr_0_lbreq_pending_f(void)
402{
403 return 0x100;
404}
405static inline u32 pbdma_intr_0_lback_timeout_pending_f(void)
406{
407 return 0x200;
408}
409static inline u32 pbdma_intr_0_lback_extra_pending_f(void)
410{
411 return 0x400;
412}
413static inline u32 pbdma_intr_0_lbdat_timeout_pending_f(void)
414{
415 return 0x800;
416}
417static inline u32 pbdma_intr_0_lbdat_extra_pending_f(void)
418{
419 return 0x1000;
420}
421static inline u32 pbdma_intr_0_gpfifo_pending_f(void)
422{
423 return 0x2000;
424}
425static inline u32 pbdma_intr_0_gpptr_pending_f(void)
426{
427 return 0x4000;
428}
429static inline u32 pbdma_intr_0_gpentry_pending_f(void)
430{
431 return 0x8000;
432}
433static inline u32 pbdma_intr_0_gpcrc_pending_f(void)
434{
435 return 0x10000;
436}
437static inline u32 pbdma_intr_0_pbptr_pending_f(void)
438{
439 return 0x20000;
440}
441static inline u32 pbdma_intr_0_pbentry_pending_f(void)
442{
443 return 0x40000;
444}
445static inline u32 pbdma_intr_0_pbcrc_pending_f(void)
446{
447 return 0x80000;
448}
449static inline u32 pbdma_intr_0_xbarconnect_pending_f(void)
450{
451 return 0x100000;
452}
453static inline u32 pbdma_intr_0_method_pending_f(void)
454{
455 return 0x200000;
456}
457static inline u32 pbdma_intr_0_methodcrc_pending_f(void)
458{
459 return 0x400000;
460}
461static inline u32 pbdma_intr_0_device_pending_f(void)
462{
463 return 0x800000;
464}
465static inline u32 pbdma_intr_0_semaphore_pending_f(void)
466{
467 return 0x2000000;
468}
469static inline u32 pbdma_intr_0_acquire_pending_f(void)
470{
471 return 0x4000000;
472}
473static inline u32 pbdma_intr_0_pri_pending_f(void)
474{
475 return 0x8000000;
476}
477static inline u32 pbdma_intr_0_no_ctxsw_seg_pending_f(void)
478{
479 return 0x20000000;
480}
481static inline u32 pbdma_intr_0_pbseg_pending_f(void)
482{
483 return 0x40000000;
484}
485static inline u32 pbdma_intr_0_signature_pending_f(void)
486{
487 return 0x80000000;
488}
489static inline u32 pbdma_intr_0_syncpoint_illegal_pending_f(void)
490{
491 return 0x10000000;
492}
493static inline u32 pbdma_intr_1_r(u32 i)
494{
495 return 0x00040148 + i*8192;
496}
497static inline u32 pbdma_intr_en_0_r(u32 i)
498{
499 return 0x0004010c + i*8192;
500}
501static inline u32 pbdma_intr_en_0_lbreq_enabled_f(void)
502{
503 return 0x100;
504}
505static inline u32 pbdma_intr_en_1_r(u32 i)
506{
507 return 0x0004014c + i*8192;
508}
509static inline u32 pbdma_intr_stall_r(u32 i)
510{
511 return 0x0004013c + i*8192;
512}
513static inline u32 pbdma_intr_stall_lbreq_enabled_f(void)
514{
515 return 0x100;
516}
517static inline u32 pbdma_udma_nop_r(void)
518{
519 return 0x00000008;
520}
521static inline u32 pbdma_allowed_syncpoints_r(u32 i)
522{
523 return 0x000400e8 + i*8192;
524}
525static inline u32 pbdma_allowed_syncpoints_0_valid_f(u32 v)
526{
527 return (v & 0x1) << 31;
528}
529static inline u32 pbdma_allowed_syncpoints_0_index_f(u32 v)
530{
531 return (v & 0x7fff) << 16;
532}
533static inline u32 pbdma_allowed_syncpoints_0_index_v(u32 r)
534{
535 return (r >> 16) & 0x7fff;
536}
537static inline u32 pbdma_allowed_syncpoints_1_valid_f(u32 v)
538{
539 return (v & 0x1) << 15;
540}
541static inline u32 pbdma_allowed_syncpoints_1_index_f(u32 v)
542{
543 return (v & 0x7fff) << 0;
544}
545static inline u32 pbdma_syncpointa_r(u32 i)
546{
547 return 0x000400a4 + i*8192;
548}
549static inline u32 pbdma_syncpointa_payload_v(u32 r)
550{
551 return (r >> 0) & 0xffffffff;
552}
553static inline u32 pbdma_syncpointb_r(u32 i)
554{
555 return 0x000400a8 + i*8192;
556}
557static inline u32 pbdma_syncpointb_op_v(u32 r)
558{
559 return (r >> 0) & 0x1;
560}
561static inline u32 pbdma_syncpointb_op_wait_v(void)
562{
563 return 0x00000000;
564}
565static inline u32 pbdma_syncpointb_wait_switch_v(u32 r)
566{
567 return (r >> 4) & 0x1;
568}
569static inline u32 pbdma_syncpointb_wait_switch_en_v(void)
570{
571 return 0x00000001;
572}
573static inline u32 pbdma_syncpointb_syncpt_index_v(u32 r)
574{
575 return (r >> 8) & 0xfff;
576}
577static inline u32 pbdma_runlist_timeslice_r(u32 i)
578{
579 return 0x000400f8 + i*8192;
580}
581static inline u32 pbdma_runlist_timeslice_timeout_128_f(void)
582{
583 return 0x80;
584}
585static inline u32 pbdma_runlist_timeslice_timescale_3_f(void)
586{
587 return 0x3000;
588}
589static inline u32 pbdma_runlist_timeslice_enable_true_f(void)
590{
591 return 0x10000000;
592}
593#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_perf_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_perf_gp10b.h
new file mode 100644
index 00000000..ea1a61d2
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_perf_gp10b.h
@@ -0,0 +1,205 @@
1/*
2 * Copyright (c) 2015, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_perf_gp10b_h_
51#define _hw_perf_gp10b_h_
52
53static inline u32 perf_pmasys_control_r(void)
54{
55 return 0x001b4000;
56}
57static inline u32 perf_pmasys_control_membuf_status_v(u32 r)
58{
59 return (r >> 4) & 0x1;
60}
61static inline u32 perf_pmasys_control_membuf_status_overflowed_v(void)
62{
63 return 0x00000001;
64}
65static inline u32 perf_pmasys_control_membuf_status_overflowed_f(void)
66{
67 return 0x10;
68}
69static inline u32 perf_pmasys_control_membuf_clear_status_f(u32 v)
70{
71 return (v & 0x1) << 5;
72}
73static inline u32 perf_pmasys_control_membuf_clear_status_v(u32 r)
74{
75 return (r >> 5) & 0x1;
76}
77static inline u32 perf_pmasys_control_membuf_clear_status_doit_v(void)
78{
79 return 0x00000001;
80}
81static inline u32 perf_pmasys_control_membuf_clear_status_doit_f(void)
82{
83 return 0x20;
84}
85static inline u32 perf_pmasys_mem_block_r(void)
86{
87 return 0x001b4070;
88}
89static inline u32 perf_pmasys_mem_block_base_f(u32 v)
90{
91 return (v & 0xfffffff) << 0;
92}
93static inline u32 perf_pmasys_mem_block_target_f(u32 v)
94{
95 return (v & 0x3) << 28;
96}
97static inline u32 perf_pmasys_mem_block_target_v(u32 r)
98{
99 return (r >> 28) & 0x3;
100}
101static inline u32 perf_pmasys_mem_block_target_lfb_v(void)
102{
103 return 0x00000000;
104}
105static inline u32 perf_pmasys_mem_block_target_lfb_f(void)
106{
107 return 0x0;
108}
109static inline u32 perf_pmasys_mem_block_target_sys_coh_v(void)
110{
111 return 0x00000002;
112}
113static inline u32 perf_pmasys_mem_block_target_sys_coh_f(void)
114{
115 return 0x20000000;
116}
117static inline u32 perf_pmasys_mem_block_target_sys_ncoh_v(void)
118{
119 return 0x00000003;
120}
121static inline u32 perf_pmasys_mem_block_target_sys_ncoh_f(void)
122{
123 return 0x30000000;
124}
125static inline u32 perf_pmasys_mem_block_valid_f(u32 v)
126{
127 return (v & 0x1) << 31;
128}
129static inline u32 perf_pmasys_mem_block_valid_v(u32 r)
130{
131 return (r >> 31) & 0x1;
132}
133static inline u32 perf_pmasys_mem_block_valid_true_v(void)
134{
135 return 0x00000001;
136}
137static inline u32 perf_pmasys_mem_block_valid_true_f(void)
138{
139 return 0x80000000;
140}
141static inline u32 perf_pmasys_mem_block_valid_false_v(void)
142{
143 return 0x00000000;
144}
145static inline u32 perf_pmasys_mem_block_valid_false_f(void)
146{
147 return 0x0;
148}
149static inline u32 perf_pmasys_outbase_r(void)
150{
151 return 0x001b4074;
152}
153static inline u32 perf_pmasys_outbase_ptr_f(u32 v)
154{
155 return (v & 0x7ffffff) << 5;
156}
157static inline u32 perf_pmasys_outbaseupper_r(void)
158{
159 return 0x001b4078;
160}
161static inline u32 perf_pmasys_outbaseupper_ptr_f(u32 v)
162{
163 return (v & 0xff) << 0;
164}
165static inline u32 perf_pmasys_outsize_r(void)
166{
167 return 0x001b407c;
168}
169static inline u32 perf_pmasys_outsize_numbytes_f(u32 v)
170{
171 return (v & 0x7ffffff) << 5;
172}
173static inline u32 perf_pmasys_mem_bytes_r(void)
174{
175 return 0x001b4084;
176}
177static inline u32 perf_pmasys_mem_bytes_numbytes_f(u32 v)
178{
179 return (v & 0xfffffff) << 4;
180}
181static inline u32 perf_pmasys_mem_bump_r(void)
182{
183 return 0x001b4088;
184}
185static inline u32 perf_pmasys_mem_bump_numbytes_f(u32 v)
186{
187 return (v & 0xfffffff) << 4;
188}
189static inline u32 perf_pmasys_enginestatus_r(void)
190{
191 return 0x001b40a4;
192}
193static inline u32 perf_pmasys_enginestatus_rbufempty_f(u32 v)
194{
195 return (v & 0x1) << 4;
196}
197static inline u32 perf_pmasys_enginestatus_rbufempty_empty_v(void)
198{
199 return 0x00000001;
200}
201static inline u32 perf_pmasys_enginestatus_rbufempty_empty_f(void)
202{
203 return 0x10;
204}
205#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_pram_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_pram_gp10b.h
new file mode 100644
index 00000000..12a83a71
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_pram_gp10b.h
@@ -0,0 +1,57 @@
1/*
2 * Copyright (c) 2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_pram_gp10b_h_
51#define _hw_pram_gp10b_h_
52
53static inline u32 pram_data032_r(u32 i)
54{
55 return 0x00700000 + i*4;
56}
57#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_pri_ringmaster_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_pri_ringmaster_gp10b.h
new file mode 100644
index 00000000..7a458858
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_pri_ringmaster_gp10b.h
@@ -0,0 +1,145 @@
1/*
2 * Copyright (c) 2014, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_pri_ringmaster_gp10b_h_
51#define _hw_pri_ringmaster_gp10b_h_
52
53static inline u32 pri_ringmaster_command_r(void)
54{
55 return 0x0012004c;
56}
57static inline u32 pri_ringmaster_command_cmd_m(void)
58{
59 return 0x3f << 0;
60}
61static inline u32 pri_ringmaster_command_cmd_v(u32 r)
62{
63 return (r >> 0) & 0x3f;
64}
65static inline u32 pri_ringmaster_command_cmd_no_cmd_v(void)
66{
67 return 0x00000000;
68}
69static inline u32 pri_ringmaster_command_cmd_start_ring_f(void)
70{
71 return 0x1;
72}
73static inline u32 pri_ringmaster_command_cmd_ack_interrupt_f(void)
74{
75 return 0x2;
76}
77static inline u32 pri_ringmaster_command_cmd_enumerate_stations_f(void)
78{
79 return 0x3;
80}
81static inline u32 pri_ringmaster_command_cmd_enumerate_stations_bc_grp_all_f(void)
82{
83 return 0x0;
84}
85static inline u32 pri_ringmaster_command_data_r(void)
86{
87 return 0x00120048;
88}
89static inline u32 pri_ringmaster_start_results_r(void)
90{
91 return 0x00120050;
92}
93static inline u32 pri_ringmaster_start_results_connectivity_v(u32 r)
94{
95 return (r >> 0) & 0x1;
96}
97static inline u32 pri_ringmaster_start_results_connectivity_pass_v(void)
98{
99 return 0x00000001;
100}
101static inline u32 pri_ringmaster_intr_status0_r(void)
102{
103 return 0x00120058;
104}
105static inline u32 pri_ringmaster_intr_status1_r(void)
106{
107 return 0x0012005c;
108}
109static inline u32 pri_ringmaster_global_ctl_r(void)
110{
111 return 0x00120060;
112}
113static inline u32 pri_ringmaster_global_ctl_ring_reset_asserted_f(void)
114{
115 return 0x1;
116}
117static inline u32 pri_ringmaster_global_ctl_ring_reset_deasserted_f(void)
118{
119 return 0x0;
120}
121static inline u32 pri_ringmaster_enum_fbp_r(void)
122{
123 return 0x00120074;
124}
125static inline u32 pri_ringmaster_enum_fbp_count_v(u32 r)
126{
127 return (r >> 0) & 0x1f;
128}
129static inline u32 pri_ringmaster_enum_gpc_r(void)
130{
131 return 0x00120078;
132}
133static inline u32 pri_ringmaster_enum_gpc_count_v(u32 r)
134{
135 return (r >> 0) & 0x1f;
136}
137static inline u32 pri_ringmaster_enum_ltc_r(void)
138{
139 return 0x0012006c;
140}
141static inline u32 pri_ringmaster_enum_ltc_count_v(u32 r)
142{
143 return (r >> 0) & 0x1f;
144}
145#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_pri_ringstation_sys_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_pri_ringstation_sys_gp10b.h
new file mode 100644
index 00000000..eb711452
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_pri_ringstation_sys_gp10b.h
@@ -0,0 +1,69 @@
1/*
2 * Copyright (c) 2014, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_pri_ringstation_sys_gp10b_h_
51#define _hw_pri_ringstation_sys_gp10b_h_
52
53static inline u32 pri_ringstation_sys_master_config_r(u32 i)
54{
55 return 0x00122300 + i*4;
56}
57static inline u32 pri_ringstation_sys_decode_config_r(void)
58{
59 return 0x00122204;
60}
61static inline u32 pri_ringstation_sys_decode_config_ring_m(void)
62{
63 return 0x7 << 0;
64}
65static inline u32 pri_ringstation_sys_decode_config_ring_drop_on_ring_not_started_f(void)
66{
67 return 0x1;
68}
69#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_proj_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_proj_gp10b.h
new file mode 100644
index 00000000..3392242c
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_proj_gp10b.h
@@ -0,0 +1,165 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_proj_gp10b_h_
51#define _hw_proj_gp10b_h_
52
53static inline u32 proj_gpc_base_v(void)
54{
55 return 0x00500000;
56}
57static inline u32 proj_gpc_shared_base_v(void)
58{
59 return 0x00418000;
60}
61static inline u32 proj_gpc_stride_v(void)
62{
63 return 0x00008000;
64}
65static inline u32 proj_ltc_stride_v(void)
66{
67 return 0x00002000;
68}
69static inline u32 proj_lts_stride_v(void)
70{
71 return 0x00000200;
72}
73static inline u32 proj_fbpa_base_v(void)
74{
75 return 0x00900000;
76}
77static inline u32 proj_fbpa_shared_base_v(void)
78{
79 return 0x009a0000;
80}
81static inline u32 proj_fbpa_stride_v(void)
82{
83 return 0x00004000;
84}
85static inline u32 proj_ppc_in_gpc_base_v(void)
86{
87 return 0x00003000;
88}
89static inline u32 proj_ppc_in_gpc_shared_base_v(void)
90{
91 return 0x00003e00;
92}
93static inline u32 proj_ppc_in_gpc_stride_v(void)
94{
95 return 0x00000200;
96}
97static inline u32 proj_rop_base_v(void)
98{
99 return 0x00410000;
100}
101static inline u32 proj_rop_shared_base_v(void)
102{
103 return 0x00408800;
104}
105static inline u32 proj_rop_stride_v(void)
106{
107 return 0x00000400;
108}
109static inline u32 proj_tpc_in_gpc_base_v(void)
110{
111 return 0x00004000;
112}
113static inline u32 proj_tpc_in_gpc_stride_v(void)
114{
115 return 0x00000800;
116}
117static inline u32 proj_tpc_in_gpc_shared_base_v(void)
118{
119 return 0x00001800;
120}
121static inline u32 proj_host_num_engines_v(void)
122{
123 return 0x00000002;
124}
125static inline u32 proj_host_num_pbdma_v(void)
126{
127 return 0x00000001;
128}
129static inline u32 proj_scal_litter_num_tpc_per_gpc_v(void)
130{
131 return 0x00000002;
132}
133static inline u32 proj_scal_litter_num_fbps_v(void)
134{
135 return 0x00000001;
136}
137static inline u32 proj_scal_litter_num_fbpas_v(void)
138{
139 return 0x00000001;
140}
141static inline u32 proj_scal_litter_num_gpcs_v(void)
142{
143 return 0x00000001;
144}
145static inline u32 proj_scal_litter_num_pes_per_gpc_v(void)
146{
147 return 0x00000001;
148}
149static inline u32 proj_scal_litter_num_tpcs_per_pes_v(void)
150{
151 return 0x00000002;
152}
153static inline u32 proj_scal_litter_num_zcull_banks_v(void)
154{
155 return 0x00000004;
156}
157static inline u32 proj_scal_max_gpcs_v(void)
158{
159 return 0x00000020;
160}
161static inline u32 proj_scal_max_tpc_per_gpc_v(void)
162{
163 return 0x00000008;
164}
165#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_pwr_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_pwr_gp10b.h
new file mode 100644
index 00000000..9a3591c7
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_pwr_gp10b.h
@@ -0,0 +1,825 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_pwr_gp10b_h_
51#define _hw_pwr_gp10b_h_
52
53static inline u32 pwr_falcon_irqsset_r(void)
54{
55 return 0x0010a000;
56}
57static inline u32 pwr_falcon_irqsset_swgen0_set_f(void)
58{
59 return 0x40;
60}
61static inline u32 pwr_falcon_irqsclr_r(void)
62{
63 return 0x0010a004;
64}
65static inline u32 pwr_falcon_irqstat_r(void)
66{
67 return 0x0010a008;
68}
69static inline u32 pwr_falcon_irqstat_halt_true_f(void)
70{
71 return 0x10;
72}
73static inline u32 pwr_falcon_irqstat_exterr_true_f(void)
74{
75 return 0x20;
76}
77static inline u32 pwr_falcon_irqstat_swgen0_true_f(void)
78{
79 return 0x40;
80}
81static inline u32 pwr_falcon_irqmode_r(void)
82{
83 return 0x0010a00c;
84}
85static inline u32 pwr_falcon_irqmset_r(void)
86{
87 return 0x0010a010;
88}
89static inline u32 pwr_falcon_irqmset_gptmr_f(u32 v)
90{
91 return (v & 0x1) << 0;
92}
93static inline u32 pwr_falcon_irqmset_wdtmr_f(u32 v)
94{
95 return (v & 0x1) << 1;
96}
97static inline u32 pwr_falcon_irqmset_mthd_f(u32 v)
98{
99 return (v & 0x1) << 2;
100}
101static inline u32 pwr_falcon_irqmset_ctxsw_f(u32 v)
102{
103 return (v & 0x1) << 3;
104}
105static inline u32 pwr_falcon_irqmset_halt_f(u32 v)
106{
107 return (v & 0x1) << 4;
108}
109static inline u32 pwr_falcon_irqmset_exterr_f(u32 v)
110{
111 return (v & 0x1) << 5;
112}
113static inline u32 pwr_falcon_irqmset_swgen0_f(u32 v)
114{
115 return (v & 0x1) << 6;
116}
117static inline u32 pwr_falcon_irqmset_swgen1_f(u32 v)
118{
119 return (v & 0x1) << 7;
120}
121static inline u32 pwr_falcon_irqmclr_r(void)
122{
123 return 0x0010a014;
124}
125static inline u32 pwr_falcon_irqmclr_gptmr_f(u32 v)
126{
127 return (v & 0x1) << 0;
128}
129static inline u32 pwr_falcon_irqmclr_wdtmr_f(u32 v)
130{
131 return (v & 0x1) << 1;
132}
133static inline u32 pwr_falcon_irqmclr_mthd_f(u32 v)
134{
135 return (v & 0x1) << 2;
136}
137static inline u32 pwr_falcon_irqmclr_ctxsw_f(u32 v)
138{
139 return (v & 0x1) << 3;
140}
141static inline u32 pwr_falcon_irqmclr_halt_f(u32 v)
142{
143 return (v & 0x1) << 4;
144}
145static inline u32 pwr_falcon_irqmclr_exterr_f(u32 v)
146{
147 return (v & 0x1) << 5;
148}
149static inline u32 pwr_falcon_irqmclr_swgen0_f(u32 v)
150{
151 return (v & 0x1) << 6;
152}
153static inline u32 pwr_falcon_irqmclr_swgen1_f(u32 v)
154{
155 return (v & 0x1) << 7;
156}
157static inline u32 pwr_falcon_irqmclr_ext_f(u32 v)
158{
159 return (v & 0xff) << 8;
160}
161static inline u32 pwr_falcon_irqmask_r(void)
162{
163 return 0x0010a018;
164}
165static inline u32 pwr_falcon_irqdest_r(void)
166{
167 return 0x0010a01c;
168}
169static inline u32 pwr_falcon_irqdest_host_gptmr_f(u32 v)
170{
171 return (v & 0x1) << 0;
172}
173static inline u32 pwr_falcon_irqdest_host_wdtmr_f(u32 v)
174{
175 return (v & 0x1) << 1;
176}
177static inline u32 pwr_falcon_irqdest_host_mthd_f(u32 v)
178{
179 return (v & 0x1) << 2;
180}
181static inline u32 pwr_falcon_irqdest_host_ctxsw_f(u32 v)
182{
183 return (v & 0x1) << 3;
184}
185static inline u32 pwr_falcon_irqdest_host_halt_f(u32 v)
186{
187 return (v & 0x1) << 4;
188}
189static inline u32 pwr_falcon_irqdest_host_exterr_f(u32 v)
190{
191 return (v & 0x1) << 5;
192}
193static inline u32 pwr_falcon_irqdest_host_swgen0_f(u32 v)
194{
195 return (v & 0x1) << 6;
196}
197static inline u32 pwr_falcon_irqdest_host_swgen1_f(u32 v)
198{
199 return (v & 0x1) << 7;
200}
201static inline u32 pwr_falcon_irqdest_host_ext_f(u32 v)
202{
203 return (v & 0xff) << 8;
204}
205static inline u32 pwr_falcon_irqdest_target_gptmr_f(u32 v)
206{
207 return (v & 0x1) << 16;
208}
209static inline u32 pwr_falcon_irqdest_target_wdtmr_f(u32 v)
210{
211 return (v & 0x1) << 17;
212}
213static inline u32 pwr_falcon_irqdest_target_mthd_f(u32 v)
214{
215 return (v & 0x1) << 18;
216}
217static inline u32 pwr_falcon_irqdest_target_ctxsw_f(u32 v)
218{
219 return (v & 0x1) << 19;
220}
221static inline u32 pwr_falcon_irqdest_target_halt_f(u32 v)
222{
223 return (v & 0x1) << 20;
224}
225static inline u32 pwr_falcon_irqdest_target_exterr_f(u32 v)
226{
227 return (v & 0x1) << 21;
228}
229static inline u32 pwr_falcon_irqdest_target_swgen0_f(u32 v)
230{
231 return (v & 0x1) << 22;
232}
233static inline u32 pwr_falcon_irqdest_target_swgen1_f(u32 v)
234{
235 return (v & 0x1) << 23;
236}
237static inline u32 pwr_falcon_irqdest_target_ext_f(u32 v)
238{
239 return (v & 0xff) << 24;
240}
241static inline u32 pwr_falcon_curctx_r(void)
242{
243 return 0x0010a050;
244}
245static inline u32 pwr_falcon_nxtctx_r(void)
246{
247 return 0x0010a054;
248}
249static inline u32 pwr_falcon_mailbox0_r(void)
250{
251 return 0x0010a040;
252}
253static inline u32 pwr_falcon_mailbox1_r(void)
254{
255 return 0x0010a044;
256}
257static inline u32 pwr_falcon_itfen_r(void)
258{
259 return 0x0010a048;
260}
261static inline u32 pwr_falcon_itfen_ctxen_enable_f(void)
262{
263 return 0x1;
264}
265static inline u32 pwr_falcon_idlestate_r(void)
266{
267 return 0x0010a04c;
268}
269static inline u32 pwr_falcon_idlestate_falcon_busy_v(u32 r)
270{
271 return (r >> 0) & 0x1;
272}
273static inline u32 pwr_falcon_idlestate_ext_busy_v(u32 r)
274{
275 return (r >> 1) & 0x7fff;
276}
277static inline u32 pwr_falcon_os_r(void)
278{
279 return 0x0010a080;
280}
281static inline u32 pwr_falcon_engctl_r(void)
282{
283 return 0x0010a0a4;
284}
285static inline u32 pwr_falcon_cpuctl_r(void)
286{
287 return 0x0010a100;
288}
289static inline u32 pwr_falcon_cpuctl_startcpu_f(u32 v)
290{
291 return (v & 0x1) << 1;
292}
293static inline u32 pwr_falcon_cpuctl_halt_intr_f(u32 v)
294{
295 return (v & 0x1) << 4;
296}
297static inline u32 pwr_falcon_cpuctl_halt_intr_m(void)
298{
299 return 0x1 << 4;
300}
301static inline u32 pwr_falcon_cpuctl_halt_intr_v(u32 r)
302{
303 return (r >> 4) & 0x1;
304}
305static inline u32 pwr_falcon_cpuctl_cpuctl_alias_en_f(u32 v)
306{
307 return (v & 0x1) << 6;
308}
309static inline u32 pwr_falcon_cpuctl_cpuctl_alias_en_m(void)
310{
311 return 0x1 << 6;
312}
313static inline u32 pwr_falcon_cpuctl_cpuctl_alias_en_v(u32 r)
314{
315 return (r >> 6) & 0x1;
316}
317static inline u32 pwr_falcon_cpuctl_alias_r(void)
318{
319 return 0x0010a130;
320}
321static inline u32 pwr_falcon_cpuctl_alias_startcpu_f(u32 v)
322{
323 return (v & 0x1) << 1;
324}
325static inline u32 pwr_pmu_scpctl_stat_r(void)
326{
327 return 0x0010ac08;
328}
329static inline u32 pwr_pmu_scpctl_stat_debug_mode_f(u32 v)
330{
331 return (v & 0x1) << 20;
332}
333static inline u32 pwr_pmu_scpctl_stat_debug_mode_m(void)
334{
335 return 0x1 << 20;
336}
337static inline u32 pwr_pmu_scpctl_stat_debug_mode_v(u32 r)
338{
339 return (r >> 20) & 0x1;
340}
341static inline u32 pwr_falcon_imemc_r(u32 i)
342{
343 return 0x0010a180 + i*16;
344}
345static inline u32 pwr_falcon_imemc_offs_f(u32 v)
346{
347 return (v & 0x3f) << 2;
348}
349static inline u32 pwr_falcon_imemc_blk_f(u32 v)
350{
351 return (v & 0xff) << 8;
352}
353static inline u32 pwr_falcon_imemc_aincw_f(u32 v)
354{
355 return (v & 0x1) << 24;
356}
357static inline u32 pwr_falcon_imemd_r(u32 i)
358{
359 return 0x0010a184 + i*16;
360}
361static inline u32 pwr_falcon_imemt_r(u32 i)
362{
363 return 0x0010a188 + i*16;
364}
365static inline u32 pwr_falcon_sctl_r(void)
366{
367 return 0x0010a240;
368}
369static inline u32 pwr_falcon_mmu_phys_sec_r(void)
370{
371 return 0x00100ce4;
372}
373static inline u32 pwr_falcon_bootvec_r(void)
374{
375 return 0x0010a104;
376}
377static inline u32 pwr_falcon_bootvec_vec_f(u32 v)
378{
379 return (v & 0xffffffff) << 0;
380}
381static inline u32 pwr_falcon_dmactl_r(void)
382{
383 return 0x0010a10c;
384}
385static inline u32 pwr_falcon_dmactl_dmem_scrubbing_m(void)
386{
387 return 0x1 << 1;
388}
389static inline u32 pwr_falcon_dmactl_imem_scrubbing_m(void)
390{
391 return 0x1 << 2;
392}
393static inline u32 pwr_falcon_hwcfg_r(void)
394{
395 return 0x0010a108;
396}
397static inline u32 pwr_falcon_hwcfg_imem_size_v(u32 r)
398{
399 return (r >> 0) & 0x1ff;
400}
401static inline u32 pwr_falcon_hwcfg_dmem_size_v(u32 r)
402{
403 return (r >> 9) & 0x1ff;
404}
405static inline u32 pwr_falcon_dmatrfbase_r(void)
406{
407 return 0x0010a110;
408}
409static inline u32 pwr_falcon_dmatrfbase1_r(void)
410{
411 return 0x0010a128;
412}
413static inline u32 pwr_falcon_dmatrfmoffs_r(void)
414{
415 return 0x0010a114;
416}
417static inline u32 pwr_falcon_dmatrfcmd_r(void)
418{
419 return 0x0010a118;
420}
421static inline u32 pwr_falcon_dmatrfcmd_imem_f(u32 v)
422{
423 return (v & 0x1) << 4;
424}
425static inline u32 pwr_falcon_dmatrfcmd_write_f(u32 v)
426{
427 return (v & 0x1) << 5;
428}
429static inline u32 pwr_falcon_dmatrfcmd_size_f(u32 v)
430{
431 return (v & 0x7) << 8;
432}
433static inline u32 pwr_falcon_dmatrfcmd_ctxdma_f(u32 v)
434{
435 return (v & 0x7) << 12;
436}
437static inline u32 pwr_falcon_dmatrffboffs_r(void)
438{
439 return 0x0010a11c;
440}
441static inline u32 pwr_falcon_exterraddr_r(void)
442{
443 return 0x0010a168;
444}
445static inline u32 pwr_falcon_exterrstat_r(void)
446{
447 return 0x0010a16c;
448}
449static inline u32 pwr_falcon_exterrstat_valid_m(void)
450{
451 return 0x1 << 31;
452}
453static inline u32 pwr_falcon_exterrstat_valid_v(u32 r)
454{
455 return (r >> 31) & 0x1;
456}
457static inline u32 pwr_falcon_exterrstat_valid_true_v(void)
458{
459 return 0x00000001;
460}
461static inline u32 pwr_pmu_falcon_icd_cmd_r(void)
462{
463 return 0x0010a200;
464}
465static inline u32 pwr_pmu_falcon_icd_cmd_opc_s(void)
466{
467 return 4;
468}
469static inline u32 pwr_pmu_falcon_icd_cmd_opc_f(u32 v)
470{
471 return (v & 0xf) << 0;
472}
473static inline u32 pwr_pmu_falcon_icd_cmd_opc_m(void)
474{
475 return 0xf << 0;
476}
477static inline u32 pwr_pmu_falcon_icd_cmd_opc_v(u32 r)
478{
479 return (r >> 0) & 0xf;
480}
481static inline u32 pwr_pmu_falcon_icd_cmd_opc_rreg_f(void)
482{
483 return 0x8;
484}
485static inline u32 pwr_pmu_falcon_icd_cmd_opc_rstat_f(void)
486{
487 return 0xe;
488}
489static inline u32 pwr_pmu_falcon_icd_cmd_idx_f(u32 v)
490{
491 return (v & 0x1f) << 8;
492}
493static inline u32 pwr_pmu_falcon_icd_rdata_r(void)
494{
495 return 0x0010a20c;
496}
497static inline u32 pwr_falcon_dmemc_r(u32 i)
498{
499 return 0x0010a1c0 + i*8;
500}
501static inline u32 pwr_falcon_dmemc_offs_f(u32 v)
502{
503 return (v & 0x3f) << 2;
504}
505static inline u32 pwr_falcon_dmemc_offs_m(void)
506{
507 return 0x3f << 2;
508}
509static inline u32 pwr_falcon_dmemc_blk_f(u32 v)
510{
511 return (v & 0xff) << 8;
512}
513static inline u32 pwr_falcon_dmemc_blk_m(void)
514{
515 return 0xff << 8;
516}
517static inline u32 pwr_falcon_dmemc_aincw_f(u32 v)
518{
519 return (v & 0x1) << 24;
520}
521static inline u32 pwr_falcon_dmemc_aincr_f(u32 v)
522{
523 return (v & 0x1) << 25;
524}
525static inline u32 pwr_falcon_dmemd_r(u32 i)
526{
527 return 0x0010a1c4 + i*8;
528}
529static inline u32 pwr_pmu_new_instblk_r(void)
530{
531 return 0x0010a480;
532}
533static inline u32 pwr_pmu_new_instblk_ptr_f(u32 v)
534{
535 return (v & 0xfffffff) << 0;
536}
537static inline u32 pwr_pmu_new_instblk_target_fb_f(void)
538{
539 return 0x0;
540}
541static inline u32 pwr_pmu_new_instblk_target_sys_coh_f(void)
542{
543 return 0x20000000;
544}
545static inline u32 pwr_pmu_new_instblk_target_sys_ncoh_f(void)
546{
547 return 0x30000000;
548}
549static inline u32 pwr_pmu_new_instblk_valid_f(u32 v)
550{
551 return (v & 0x1) << 30;
552}
553static inline u32 pwr_pmu_mutex_id_r(void)
554{
555 return 0x0010a488;
556}
557static inline u32 pwr_pmu_mutex_id_value_v(u32 r)
558{
559 return (r >> 0) & 0xff;
560}
561static inline u32 pwr_pmu_mutex_id_value_init_v(void)
562{
563 return 0x00000000;
564}
565static inline u32 pwr_pmu_mutex_id_value_not_avail_v(void)
566{
567 return 0x000000ff;
568}
569static inline u32 pwr_pmu_mutex_id_release_r(void)
570{
571 return 0x0010a48c;
572}
573static inline u32 pwr_pmu_mutex_id_release_value_f(u32 v)
574{
575 return (v & 0xff) << 0;
576}
577static inline u32 pwr_pmu_mutex_id_release_value_m(void)
578{
579 return 0xff << 0;
580}
581static inline u32 pwr_pmu_mutex_id_release_value_init_v(void)
582{
583 return 0x00000000;
584}
585static inline u32 pwr_pmu_mutex_id_release_value_init_f(void)
586{
587 return 0x0;
588}
589static inline u32 pwr_pmu_mutex_r(u32 i)
590{
591 return 0x0010a580 + i*4;
592}
593static inline u32 pwr_pmu_mutex__size_1_v(void)
594{
595 return 0x00000010;
596}
597static inline u32 pwr_pmu_mutex_value_f(u32 v)
598{
599 return (v & 0xff) << 0;
600}
601static inline u32 pwr_pmu_mutex_value_v(u32 r)
602{
603 return (r >> 0) & 0xff;
604}
605static inline u32 pwr_pmu_mutex_value_initial_lock_f(void)
606{
607 return 0x0;
608}
609static inline u32 pwr_pmu_queue_head_r(u32 i)
610{
611 return 0x0010a4a0 + i*4;
612}
613static inline u32 pwr_pmu_queue_head__size_1_v(void)
614{
615 return 0x00000004;
616}
617static inline u32 pwr_pmu_queue_head_address_f(u32 v)
618{
619 return (v & 0xffffffff) << 0;
620}
621static inline u32 pwr_pmu_queue_head_address_v(u32 r)
622{
623 return (r >> 0) & 0xffffffff;
624}
625static inline u32 pwr_pmu_queue_tail_r(u32 i)
626{
627 return 0x0010a4b0 + i*4;
628}
629static inline u32 pwr_pmu_queue_tail__size_1_v(void)
630{
631 return 0x00000004;
632}
633static inline u32 pwr_pmu_queue_tail_address_f(u32 v)
634{
635 return (v & 0xffffffff) << 0;
636}
637static inline u32 pwr_pmu_queue_tail_address_v(u32 r)
638{
639 return (r >> 0) & 0xffffffff;
640}
641static inline u32 pwr_pmu_msgq_head_r(void)
642{
643 return 0x0010a4c8;
644}
645static inline u32 pwr_pmu_msgq_head_val_f(u32 v)
646{
647 return (v & 0xffffffff) << 0;
648}
649static inline u32 pwr_pmu_msgq_head_val_v(u32 r)
650{
651 return (r >> 0) & 0xffffffff;
652}
653static inline u32 pwr_pmu_msgq_tail_r(void)
654{
655 return 0x0010a4cc;
656}
657static inline u32 pwr_pmu_msgq_tail_val_f(u32 v)
658{
659 return (v & 0xffffffff) << 0;
660}
661static inline u32 pwr_pmu_msgq_tail_val_v(u32 r)
662{
663 return (r >> 0) & 0xffffffff;
664}
665static inline u32 pwr_pmu_idle_mask_r(u32 i)
666{
667 return 0x0010a504 + i*16;
668}
669static inline u32 pwr_pmu_idle_mask_gr_enabled_f(void)
670{
671 return 0x1;
672}
673static inline u32 pwr_pmu_idle_mask_ce_2_enabled_f(void)
674{
675 return 0x200000;
676}
677static inline u32 pwr_pmu_idle_count_r(u32 i)
678{
679 return 0x0010a508 + i*16;
680}
681static inline u32 pwr_pmu_idle_count_value_f(u32 v)
682{
683 return (v & 0x7fffffff) << 0;
684}
685static inline u32 pwr_pmu_idle_count_value_v(u32 r)
686{
687 return (r >> 0) & 0x7fffffff;
688}
689static inline u32 pwr_pmu_idle_count_reset_f(u32 v)
690{
691 return (v & 0x1) << 31;
692}
693static inline u32 pwr_pmu_idle_ctrl_r(u32 i)
694{
695 return 0x0010a50c + i*16;
696}
697static inline u32 pwr_pmu_idle_ctrl_value_m(void)
698{
699 return 0x3 << 0;
700}
701static inline u32 pwr_pmu_idle_ctrl_value_busy_f(void)
702{
703 return 0x2;
704}
705static inline u32 pwr_pmu_idle_ctrl_value_always_f(void)
706{
707 return 0x3;
708}
709static inline u32 pwr_pmu_idle_ctrl_filter_m(void)
710{
711 return 0x1 << 2;
712}
713static inline u32 pwr_pmu_idle_ctrl_filter_disabled_f(void)
714{
715 return 0x0;
716}
717static inline u32 pwr_pmu_idle_mask_supp_r(u32 i)
718{
719 return 0x0010a9f0 + i*8;
720}
721static inline u32 pwr_pmu_idle_mask_1_supp_r(u32 i)
722{
723 return 0x0010a9f4 + i*8;
724}
725static inline u32 pwr_pmu_idle_ctrl_supp_r(u32 i)
726{
727 return 0x0010aa30 + i*8;
728}
729static inline u32 pwr_pmu_debug_r(u32 i)
730{
731 return 0x0010a5c0 + i*4;
732}
733static inline u32 pwr_pmu_debug__size_1_v(void)
734{
735 return 0x00000004;
736}
737static inline u32 pwr_pmu_mailbox_r(u32 i)
738{
739 return 0x0010a450 + i*4;
740}
741static inline u32 pwr_pmu_mailbox__size_1_v(void)
742{
743 return 0x0000000c;
744}
745static inline u32 pwr_pmu_bar0_addr_r(void)
746{
747 return 0x0010a7a0;
748}
749static inline u32 pwr_pmu_bar0_data_r(void)
750{
751 return 0x0010a7a4;
752}
753static inline u32 pwr_pmu_bar0_ctl_r(void)
754{
755 return 0x0010a7ac;
756}
757static inline u32 pwr_pmu_bar0_timeout_r(void)
758{
759 return 0x0010a7a8;
760}
761static inline u32 pwr_pmu_bar0_fecs_error_r(void)
762{
763 return 0x0010a988;
764}
765static inline u32 pwr_pmu_bar0_error_status_r(void)
766{
767 return 0x0010a7b0;
768}
769static inline u32 pwr_pmu_pg_idlefilth_r(u32 i)
770{
771 return 0x0010a6c0 + i*4;
772}
773static inline u32 pwr_pmu_pg_ppuidlefilth_r(u32 i)
774{
775 return 0x0010a6e8 + i*4;
776}
777static inline u32 pwr_pmu_pg_idle_cnt_r(u32 i)
778{
779 return 0x0010a710 + i*4;
780}
781static inline u32 pwr_pmu_pg_intren_r(u32 i)
782{
783 return 0x0010a760 + i*4;
784}
785static inline u32 pwr_fbif_transcfg_r(u32 i)
786{
787 return 0x0010ae00 + i*4;
788}
789static inline u32 pwr_fbif_transcfg_target_local_fb_f(void)
790{
791 return 0x0;
792}
793static inline u32 pwr_fbif_transcfg_target_coherent_sysmem_f(void)
794{
795 return 0x1;
796}
797static inline u32 pwr_fbif_transcfg_target_noncoherent_sysmem_f(void)
798{
799 return 0x2;
800}
801static inline u32 pwr_fbif_transcfg_mem_type_s(void)
802{
803 return 1;
804}
805static inline u32 pwr_fbif_transcfg_mem_type_f(u32 v)
806{
807 return (v & 0x1) << 2;
808}
809static inline u32 pwr_fbif_transcfg_mem_type_m(void)
810{
811 return 0x1 << 2;
812}
813static inline u32 pwr_fbif_transcfg_mem_type_v(u32 r)
814{
815 return (r >> 2) & 0x1;
816}
817static inline u32 pwr_fbif_transcfg_mem_type_virtual_f(void)
818{
819 return 0x0;
820}
821static inline u32 pwr_fbif_transcfg_mem_type_physical_f(void)
822{
823 return 0x4;
824}
825#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_ram_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_ram_gp10b.h
new file mode 100644
index 00000000..89dfbc21
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_ram_gp10b.h
@@ -0,0 +1,493 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_ram_gp10b_h_
51#define _hw_ram_gp10b_h_
52
53static inline u32 ram_in_ramfc_s(void)
54{
55 return 4096;
56}
57static inline u32 ram_in_ramfc_w(void)
58{
59 return 0;
60}
61static inline u32 ram_in_page_dir_base_target_f(u32 v)
62{
63 return (v & 0x3) << 0;
64}
65static inline u32 ram_in_page_dir_base_target_w(void)
66{
67 return 128;
68}
69static inline u32 ram_in_page_dir_base_target_vid_mem_f(void)
70{
71 return 0x0;
72}
73static inline u32 ram_in_page_dir_base_target_sys_mem_coh_f(void)
74{
75 return 0x2;
76}
77static inline u32 ram_in_page_dir_base_target_sys_mem_ncoh_f(void)
78{
79 return 0x3;
80}
81static inline u32 ram_in_page_dir_base_vol_w(void)
82{
83 return 128;
84}
85static inline u32 ram_in_page_dir_base_vol_true_f(void)
86{
87 return 0x4;
88}
89static inline u32 ram_in_page_dir_base_fault_replay_tex_f(u32 v)
90{
91 return (v & 0x1) << 4;
92}
93static inline u32 ram_in_page_dir_base_fault_replay_tex_m(void)
94{
95 return 0x1 << 4;
96}
97static inline u32 ram_in_page_dir_base_fault_replay_tex_w(void)
98{
99 return 128;
100}
101static inline u32 ram_in_page_dir_base_fault_replay_tex_true_f(void)
102{
103 return 0x10;
104}
105static inline u32 ram_in_page_dir_base_fault_replay_gcc_f(u32 v)
106{
107 return (v & 0x1) << 5;
108}
109static inline u32 ram_in_page_dir_base_fault_replay_gcc_m(void)
110{
111 return 0x1 << 5;
112}
113static inline u32 ram_in_page_dir_base_fault_replay_gcc_w(void)
114{
115 return 128;
116}
117static inline u32 ram_in_page_dir_base_fault_replay_gcc_true_f(void)
118{
119 return 0x20;
120}
121static inline u32 ram_in_big_page_size_f(u32 v)
122{
123 return (v & 0x1) << 11;
124}
125static inline u32 ram_in_big_page_size_m(void)
126{
127 return 0x1 << 11;
128}
129static inline u32 ram_in_big_page_size_w(void)
130{
131 return 128;
132}
133static inline u32 ram_in_big_page_size_128kb_f(void)
134{
135 return 0x0;
136}
137static inline u32 ram_in_big_page_size_64kb_f(void)
138{
139 return 0x800;
140}
141static inline u32 ram_in_page_dir_base_lo_f(u32 v)
142{
143 return (v & 0xfffff) << 12;
144}
145static inline u32 ram_in_page_dir_base_lo_w(void)
146{
147 return 128;
148}
149static inline u32 ram_in_page_dir_base_hi_f(u32 v)
150{
151 return (v & 0xff) << 0;
152}
153static inline u32 ram_in_page_dir_base_hi_w(void)
154{
155 return 129;
156}
157static inline u32 ram_in_adr_limit_lo_f(u32 v)
158{
159 return (v & 0xfffff) << 12;
160}
161static inline u32 ram_in_adr_limit_lo_w(void)
162{
163 return 130;
164}
165static inline u32 ram_in_adr_limit_hi_f(u32 v)
166{
167 return (v & 0xffffffff) << 0;
168}
169static inline u32 ram_in_adr_limit_hi_w(void)
170{
171 return 131;
172}
173static inline u32 ram_in_engine_cs_w(void)
174{
175 return 132;
176}
177static inline u32 ram_in_engine_cs_wfi_v(void)
178{
179 return 0x00000000;
180}
181static inline u32 ram_in_engine_cs_wfi_f(void)
182{
183 return 0x0;
184}
185static inline u32 ram_in_engine_cs_fg_v(void)
186{
187 return 0x00000001;
188}
189static inline u32 ram_in_engine_cs_fg_f(void)
190{
191 return 0x8;
192}
193static inline u32 ram_in_gr_cs_w(void)
194{
195 return 132;
196}
197static inline u32 ram_in_gr_cs_wfi_f(void)
198{
199 return 0x0;
200}
201static inline u32 ram_in_gr_wfi_target_w(void)
202{
203 return 132;
204}
205static inline u32 ram_in_gr_wfi_mode_w(void)
206{
207 return 132;
208}
209static inline u32 ram_in_gr_wfi_mode_physical_v(void)
210{
211 return 0x00000000;
212}
213static inline u32 ram_in_gr_wfi_mode_physical_f(void)
214{
215 return 0x0;
216}
217static inline u32 ram_in_gr_wfi_mode_virtual_v(void)
218{
219 return 0x00000001;
220}
221static inline u32 ram_in_gr_wfi_mode_virtual_f(void)
222{
223 return 0x4;
224}
225static inline u32 ram_in_gr_wfi_ptr_lo_f(u32 v)
226{
227 return (v & 0xfffff) << 12;
228}
229static inline u32 ram_in_gr_wfi_ptr_lo_w(void)
230{
231 return 132;
232}
233static inline u32 ram_in_gr_wfi_ptr_hi_f(u32 v)
234{
235 return (v & 0xff) << 0;
236}
237static inline u32 ram_in_gr_wfi_ptr_hi_w(void)
238{
239 return 133;
240}
241static inline u32 ram_in_base_shift_v(void)
242{
243 return 0x0000000c;
244}
245static inline u32 ram_in_alloc_size_v(void)
246{
247 return 0x00001000;
248}
249static inline u32 ram_fc_size_val_v(void)
250{
251 return 0x00000200;
252}
253static inline u32 ram_fc_gp_put_w(void)
254{
255 return 0;
256}
257static inline u32 ram_fc_userd_w(void)
258{
259 return 2;
260}
261static inline u32 ram_fc_userd_hi_w(void)
262{
263 return 3;
264}
265static inline u32 ram_fc_signature_w(void)
266{
267 return 4;
268}
269static inline u32 ram_fc_gp_get_w(void)
270{
271 return 5;
272}
273static inline u32 ram_fc_pb_get_w(void)
274{
275 return 6;
276}
277static inline u32 ram_fc_pb_get_hi_w(void)
278{
279 return 7;
280}
281static inline u32 ram_fc_pb_top_level_get_w(void)
282{
283 return 8;
284}
285static inline u32 ram_fc_pb_top_level_get_hi_w(void)
286{
287 return 9;
288}
289static inline u32 ram_fc_acquire_w(void)
290{
291 return 12;
292}
293static inline u32 ram_fc_semaphorea_w(void)
294{
295 return 14;
296}
297static inline u32 ram_fc_semaphoreb_w(void)
298{
299 return 15;
300}
301static inline u32 ram_fc_semaphorec_w(void)
302{
303 return 16;
304}
305static inline u32 ram_fc_semaphored_w(void)
306{
307 return 17;
308}
309static inline u32 ram_fc_gp_base_w(void)
310{
311 return 18;
312}
313static inline u32 ram_fc_gp_base_hi_w(void)
314{
315 return 19;
316}
317static inline u32 ram_fc_gp_fetch_w(void)
318{
319 return 20;
320}
321static inline u32 ram_fc_pb_fetch_w(void)
322{
323 return 21;
324}
325static inline u32 ram_fc_pb_fetch_hi_w(void)
326{
327 return 22;
328}
329static inline u32 ram_fc_pb_put_w(void)
330{
331 return 23;
332}
333static inline u32 ram_fc_pb_put_hi_w(void)
334{
335 return 24;
336}
337static inline u32 ram_fc_pb_header_w(void)
338{
339 return 33;
340}
341static inline u32 ram_fc_pb_count_w(void)
342{
343 return 34;
344}
345static inline u32 ram_fc_subdevice_w(void)
346{
347 return 37;
348}
349static inline u32 ram_fc_formats_w(void)
350{
351 return 39;
352}
353static inline u32 ram_fc_allowed_syncpoints_w(void)
354{
355 return 58;
356}
357static inline u32 ram_fc_syncpointa_w(void)
358{
359 return 41;
360}
361static inline u32 ram_fc_syncpointb_w(void)
362{
363 return 42;
364}
365static inline u32 ram_fc_target_w(void)
366{
367 return 43;
368}
369static inline u32 ram_fc_hce_ctrl_w(void)
370{
371 return 57;
372}
373static inline u32 ram_fc_chid_w(void)
374{
375 return 58;
376}
377static inline u32 ram_fc_chid_id_f(u32 v)
378{
379 return (v & 0xfff) << 0;
380}
381static inline u32 ram_fc_chid_id_w(void)
382{
383 return 0;
384}
385static inline u32 ram_fc_config_w(void)
386{
387 return 61;
388}
389static inline u32 ram_fc_runlist_timeslice_w(void)
390{
391 return 62;
392}
393static inline u32 ram_userd_base_shift_v(void)
394{
395 return 0x00000009;
396}
397static inline u32 ram_userd_chan_size_v(void)
398{
399 return 0x00000200;
400}
401static inline u32 ram_userd_put_w(void)
402{
403 return 16;
404}
405static inline u32 ram_userd_get_w(void)
406{
407 return 17;
408}
409static inline u32 ram_userd_ref_w(void)
410{
411 return 18;
412}
413static inline u32 ram_userd_put_hi_w(void)
414{
415 return 19;
416}
417static inline u32 ram_userd_ref_threshold_w(void)
418{
419 return 20;
420}
421static inline u32 ram_userd_top_level_get_w(void)
422{
423 return 22;
424}
425static inline u32 ram_userd_top_level_get_hi_w(void)
426{
427 return 23;
428}
429static inline u32 ram_userd_get_hi_w(void)
430{
431 return 24;
432}
433static inline u32 ram_userd_gp_get_w(void)
434{
435 return 34;
436}
437static inline u32 ram_userd_gp_put_w(void)
438{
439 return 35;
440}
441static inline u32 ram_userd_gp_top_level_get_w(void)
442{
443 return 22;
444}
445static inline u32 ram_userd_gp_top_level_get_hi_w(void)
446{
447 return 23;
448}
449static inline u32 ram_rl_entry_size_v(void)
450{
451 return 0x00000008;
452}
453static inline u32 ram_rl_entry_chid_f(u32 v)
454{
455 return (v & 0xfff) << 0;
456}
457static inline u32 ram_rl_entry_id_f(u32 v)
458{
459 return (v & 0xfff) << 0;
460}
461static inline u32 ram_rl_entry_type_f(u32 v)
462{
463 return (v & 0x1) << 13;
464}
465static inline u32 ram_rl_entry_type_chid_f(void)
466{
467 return 0x0;
468}
469static inline u32 ram_rl_entry_type_tsg_f(void)
470{
471 return 0x2000;
472}
473static inline u32 ram_rl_entry_timeslice_scale_f(u32 v)
474{
475 return (v & 0xf) << 14;
476}
477static inline u32 ram_rl_entry_timeslice_scale_3_f(void)
478{
479 return 0xc000;
480}
481static inline u32 ram_rl_entry_timeslice_timeout_f(u32 v)
482{
483 return (v & 0xff) << 18;
484}
485static inline u32 ram_rl_entry_timeslice_timeout_128_f(void)
486{
487 return 0x2000000;
488}
489static inline u32 ram_rl_entry_tsg_length_f(u32 v)
490{
491 return (v & 0x3f) << 26;
492}
493#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_therm_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_therm_gp10b.h
new file mode 100644
index 00000000..8a587b7c
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_therm_gp10b.h
@@ -0,0 +1,409 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_therm_gp10b_h_
51#define _hw_therm_gp10b_h_
52
53static inline u32 therm_use_a_r(void)
54{
55 return 0x00020798;
56}
57static inline u32 therm_use_a_ext_therm_0_enable_f(void)
58{
59 return 0x1;
60}
61static inline u32 therm_use_a_ext_therm_1_enable_f(void)
62{
63 return 0x2;
64}
65static inline u32 therm_use_a_ext_therm_2_enable_f(void)
66{
67 return 0x4;
68}
69static inline u32 therm_evt_ext_therm_0_r(void)
70{
71 return 0x00020700;
72}
73static inline u32 therm_evt_ext_therm_0_slow_factor_f(u32 v)
74{
75 return (v & 0x3f) << 24;
76}
77static inline u32 therm_evt_ext_therm_0_slow_factor_init_v(void)
78{
79 return 0x00000001;
80}
81static inline u32 therm_evt_ext_therm_0_mode_f(u32 v)
82{
83 return (v & 0x3) << 30;
84}
85static inline u32 therm_evt_ext_therm_0_mode_normal_v(void)
86{
87 return 0x00000000;
88}
89static inline u32 therm_evt_ext_therm_0_mode_inverted_v(void)
90{
91 return 0x00000001;
92}
93static inline u32 therm_evt_ext_therm_0_mode_forced_v(void)
94{
95 return 0x00000002;
96}
97static inline u32 therm_evt_ext_therm_0_mode_cleared_v(void)
98{
99 return 0x00000003;
100}
101static inline u32 therm_evt_ext_therm_1_r(void)
102{
103 return 0x00020704;
104}
105static inline u32 therm_evt_ext_therm_1_slow_factor_f(u32 v)
106{
107 return (v & 0x3f) << 24;
108}
109static inline u32 therm_evt_ext_therm_1_slow_factor_init_v(void)
110{
111 return 0x00000002;
112}
113static inline u32 therm_evt_ext_therm_1_mode_f(u32 v)
114{
115 return (v & 0x3) << 30;
116}
117static inline u32 therm_evt_ext_therm_1_mode_normal_v(void)
118{
119 return 0x00000000;
120}
121static inline u32 therm_evt_ext_therm_1_mode_inverted_v(void)
122{
123 return 0x00000001;
124}
125static inline u32 therm_evt_ext_therm_1_mode_forced_v(void)
126{
127 return 0x00000002;
128}
129static inline u32 therm_evt_ext_therm_1_mode_cleared_v(void)
130{
131 return 0x00000003;
132}
133static inline u32 therm_evt_ext_therm_2_r(void)
134{
135 return 0x00020708;
136}
137static inline u32 therm_evt_ext_therm_2_slow_factor_f(u32 v)
138{
139 return (v & 0x3f) << 24;
140}
141static inline u32 therm_evt_ext_therm_2_slow_factor_init_v(void)
142{
143 return 0x00000003;
144}
145static inline u32 therm_evt_ext_therm_2_mode_f(u32 v)
146{
147 return (v & 0x3) << 30;
148}
149static inline u32 therm_evt_ext_therm_2_mode_normal_v(void)
150{
151 return 0x00000000;
152}
153static inline u32 therm_evt_ext_therm_2_mode_inverted_v(void)
154{
155 return 0x00000001;
156}
157static inline u32 therm_evt_ext_therm_2_mode_forced_v(void)
158{
159 return 0x00000002;
160}
161static inline u32 therm_evt_ext_therm_2_mode_cleared_v(void)
162{
163 return 0x00000003;
164}
165static inline u32 therm_weight_1_r(void)
166{
167 return 0x00020024;
168}
169static inline u32 therm_config1_r(void)
170{
171 return 0x00020050;
172}
173static inline u32 therm_config2_r(void)
174{
175 return 0x00020130;
176}
177static inline u32 therm_config2_slowdown_factor_extended_f(u32 v)
178{
179 return (v & 0x1) << 24;
180}
181static inline u32 therm_config2_grad_enable_f(u32 v)
182{
183 return (v & 0x1) << 31;
184}
185static inline u32 therm_gate_ctrl_r(u32 i)
186{
187 return 0x00020200 + i*4;
188}
189static inline u32 therm_gate_ctrl_eng_clk_m(void)
190{
191 return 0x3 << 0;
192}
193static inline u32 therm_gate_ctrl_eng_clk_run_f(void)
194{
195 return 0x0;
196}
197static inline u32 therm_gate_ctrl_eng_clk_auto_f(void)
198{
199 return 0x1;
200}
201static inline u32 therm_gate_ctrl_eng_clk_stop_f(void)
202{
203 return 0x2;
204}
205static inline u32 therm_gate_ctrl_blk_clk_m(void)
206{
207 return 0x3 << 2;
208}
209static inline u32 therm_gate_ctrl_blk_clk_run_f(void)
210{
211 return 0x0;
212}
213static inline u32 therm_gate_ctrl_blk_clk_auto_f(void)
214{
215 return 0x4;
216}
217static inline u32 therm_gate_ctrl_eng_pwr_m(void)
218{
219 return 0x3 << 4;
220}
221static inline u32 therm_gate_ctrl_eng_pwr_auto_f(void)
222{
223 return 0x10;
224}
225static inline u32 therm_gate_ctrl_eng_pwr_off_v(void)
226{
227 return 0x00000002;
228}
229static inline u32 therm_gate_ctrl_eng_pwr_off_f(void)
230{
231 return 0x20;
232}
233static inline u32 therm_gate_ctrl_eng_idle_filt_exp_f(u32 v)
234{
235 return (v & 0x1f) << 8;
236}
237static inline u32 therm_gate_ctrl_eng_idle_filt_exp_m(void)
238{
239 return 0x1f << 8;
240}
241static inline u32 therm_gate_ctrl_eng_idle_filt_mant_f(u32 v)
242{
243 return (v & 0x7) << 13;
244}
245static inline u32 therm_gate_ctrl_eng_idle_filt_mant_m(void)
246{
247 return 0x7 << 13;
248}
249static inline u32 therm_gate_ctrl_eng_delay_before_f(u32 v)
250{
251 return (v & 0xf) << 16;
252}
253static inline u32 therm_gate_ctrl_eng_delay_before_m(void)
254{
255 return 0xf << 16;
256}
257static inline u32 therm_gate_ctrl_eng_delay_after_f(u32 v)
258{
259 return (v & 0xf) << 20;
260}
261static inline u32 therm_gate_ctrl_eng_delay_after_m(void)
262{
263 return 0xf << 20;
264}
265static inline u32 therm_fecs_idle_filter_r(void)
266{
267 return 0x00020288;
268}
269static inline u32 therm_fecs_idle_filter_value_m(void)
270{
271 return 0xffffffff << 0;
272}
273static inline u32 therm_hubmmu_idle_filter_r(void)
274{
275 return 0x0002028c;
276}
277static inline u32 therm_hubmmu_idle_filter_value_m(void)
278{
279 return 0xffffffff << 0;
280}
281static inline u32 therm_clk_slowdown_r(u32 i)
282{
283 return 0x00020160 + i*4;
284}
285static inline u32 therm_clk_slowdown_idle_factor_f(u32 v)
286{
287 return (v & 0x3f) << 16;
288}
289static inline u32 therm_clk_slowdown_idle_factor_m(void)
290{
291 return 0x3f << 16;
292}
293static inline u32 therm_clk_slowdown_idle_factor_v(u32 r)
294{
295 return (r >> 16) & 0x3f;
296}
297static inline u32 therm_clk_slowdown_idle_factor_disabled_f(void)
298{
299 return 0x0;
300}
301static inline u32 therm_grad_stepping_table_r(u32 i)
302{
303 return 0x000202c8 + i*4;
304}
305static inline u32 therm_grad_stepping_table_slowdown_factor0_f(u32 v)
306{
307 return (v & 0x3f) << 0;
308}
309static inline u32 therm_grad_stepping_table_slowdown_factor0_m(void)
310{
311 return 0x3f << 0;
312}
313static inline u32 therm_grad_stepping_table_slowdown_factor0_fpdiv_by1p5_f(void)
314{
315 return 0x1;
316}
317static inline u32 therm_grad_stepping_table_slowdown_factor0_fpdiv_by2_f(void)
318{
319 return 0x2;
320}
321static inline u32 therm_grad_stepping_table_slowdown_factor0_fpdiv_by4_f(void)
322{
323 return 0x6;
324}
325static inline u32 therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f(void)
326{
327 return 0xe;
328}
329static inline u32 therm_grad_stepping_table_slowdown_factor1_f(u32 v)
330{
331 return (v & 0x3f) << 6;
332}
333static inline u32 therm_grad_stepping_table_slowdown_factor1_m(void)
334{
335 return 0x3f << 6;
336}
337static inline u32 therm_grad_stepping_table_slowdown_factor2_f(u32 v)
338{
339 return (v & 0x3f) << 12;
340}
341static inline u32 therm_grad_stepping_table_slowdown_factor2_m(void)
342{
343 return 0x3f << 12;
344}
345static inline u32 therm_grad_stepping_table_slowdown_factor3_f(u32 v)
346{
347 return (v & 0x3f) << 18;
348}
349static inline u32 therm_grad_stepping_table_slowdown_factor3_m(void)
350{
351 return 0x3f << 18;
352}
353static inline u32 therm_grad_stepping_table_slowdown_factor4_f(u32 v)
354{
355 return (v & 0x3f) << 24;
356}
357static inline u32 therm_grad_stepping_table_slowdown_factor4_m(void)
358{
359 return 0x3f << 24;
360}
361static inline u32 therm_grad_stepping0_r(void)
362{
363 return 0x000202c0;
364}
365static inline u32 therm_grad_stepping0_feature_s(void)
366{
367 return 1;
368}
369static inline u32 therm_grad_stepping0_feature_f(u32 v)
370{
371 return (v & 0x1) << 0;
372}
373static inline u32 therm_grad_stepping0_feature_m(void)
374{
375 return 0x1 << 0;
376}
377static inline u32 therm_grad_stepping0_feature_v(u32 r)
378{
379 return (r >> 0) & 0x1;
380}
381static inline u32 therm_grad_stepping0_feature_enable_f(void)
382{
383 return 0x1;
384}
385static inline u32 therm_grad_stepping1_r(void)
386{
387 return 0x000202c4;
388}
389static inline u32 therm_grad_stepping1_pdiv_duration_f(u32 v)
390{
391 return (v & 0x1ffff) << 0;
392}
393static inline u32 therm_clk_timing_r(u32 i)
394{
395 return 0x000203c0 + i*4;
396}
397static inline u32 therm_clk_timing_grad_slowdown_f(u32 v)
398{
399 return (v & 0x1) << 16;
400}
401static inline u32 therm_clk_timing_grad_slowdown_m(void)
402{
403 return 0x1 << 16;
404}
405static inline u32 therm_clk_timing_grad_slowdown_enabled_f(void)
406{
407 return 0x10000;
408}
409#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_timer_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_timer_gp10b.h
new file mode 100644
index 00000000..df27154f
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_timer_gp10b.h
@@ -0,0 +1,109 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_timer_gp10b_h_
51#define _hw_timer_gp10b_h_
52
53static inline u32 timer_pri_timeout_r(void)
54{
55 return 0x00009080;
56}
57static inline u32 timer_pri_timeout_period_f(u32 v)
58{
59 return (v & 0xffffff) << 0;
60}
61static inline u32 timer_pri_timeout_period_m(void)
62{
63 return 0xffffff << 0;
64}
65static inline u32 timer_pri_timeout_period_v(u32 r)
66{
67 return (r >> 0) & 0xffffff;
68}
69static inline u32 timer_pri_timeout_en_f(u32 v)
70{
71 return (v & 0x1) << 31;
72}
73static inline u32 timer_pri_timeout_en_m(void)
74{
75 return 0x1 << 31;
76}
77static inline u32 timer_pri_timeout_en_v(u32 r)
78{
79 return (r >> 31) & 0x1;
80}
81static inline u32 timer_pri_timeout_en_en_enabled_f(void)
82{
83 return 0x80000000;
84}
85static inline u32 timer_pri_timeout_en_en_disabled_f(void)
86{
87 return 0x0;
88}
89static inline u32 timer_pri_timeout_save_0_r(void)
90{
91 return 0x00009084;
92}
93static inline u32 timer_pri_timeout_save_1_r(void)
94{
95 return 0x00009088;
96}
97static inline u32 timer_pri_timeout_fecs_errcode_r(void)
98{
99 return 0x0000908c;
100}
101static inline u32 timer_time_0_r(void)
102{
103 return 0x00009400;
104}
105static inline u32 timer_time_1_r(void)
106{
107 return 0x00009410;
108}
109#endif
diff --git a/drivers/gpu/nvgpu/gp10b/hw_top_gp10b.h b/drivers/gpu/nvgpu/gp10b/hw_top_gp10b.h
new file mode 100644
index 00000000..c6645ca0
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/hw_top_gp10b.h
@@ -0,0 +1,225 @@
1/*
2 * Copyright (c) 2014-2016, 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 * Function naming determines intended use:
18 *
19 * <x>_r(void) : Returns the offset for register <x>.
20 *
21 * <x>_o(void) : Returns the offset for element <x>.
22 *
23 * <x>_w(void) : Returns the word offset for word (4 byte) element <x>.
24 *
25 * <x>_<y>_s(void) : Returns size of field <y> of register <x> in bits.
26 *
27 * <x>_<y>_f(u32 v) : Returns a value based on 'v' which has been shifted
28 * and masked to place it at field <y> of register <x>. This value
29 * can be |'d with others to produce a full register value for
30 * register <x>.
31 *
32 * <x>_<y>_m(void) : Returns a mask for field <y> of register <x>. This
33 * value can be ~'d and then &'d to clear the value of field <y> for
34 * register <x>.
35 *
36 * <x>_<y>_<z>_f(void) : Returns the constant value <z> after being shifted
37 * to place it at field <y> of register <x>. This value can be |'d
38 * with others to produce a full register value for <x>.
39 *
40 * <x>_<y>_v(u32 r) : Returns the value of field <y> from a full register
41 * <x> value 'r' after being shifted to place its LSB at bit 0.
42 * This value is suitable for direct comparison with other unshifted
43 * values appropriate for use in field <y> of register <x>.
44 *
45 * <x>_<y>_<z>_v(void) : Returns the constant value for <z> defined for
46 * field <y> of register <x>. This value is suitable for direct
47 * comparison with unshifted values appropriate for use in field <y>
48 * of register <x>.
49 */
50#ifndef _hw_top_gp10b_h_
51#define _hw_top_gp10b_h_
52
53static inline u32 top_num_gpcs_r(void)
54{
55 return 0x00022430;
56}
57static inline u32 top_num_gpcs_value_v(u32 r)
58{
59 return (r >> 0) & 0x1f;
60}
61static inline u32 top_tpc_per_gpc_r(void)
62{
63 return 0x00022434;
64}
65static inline u32 top_tpc_per_gpc_value_v(u32 r)
66{
67 return (r >> 0) & 0x1f;
68}
69static inline u32 top_num_fbps_r(void)
70{
71 return 0x00022438;
72}
73static inline u32 top_num_fbps_value_v(u32 r)
74{
75 return (r >> 0) & 0x1f;
76}
77static inline u32 top_ltc_per_fbp_r(void)
78{
79 return 0x00022450;
80}
81static inline u32 top_ltc_per_fbp_value_v(u32 r)
82{
83 return (r >> 0) & 0x1f;
84}
85static inline u32 top_slices_per_ltc_r(void)
86{
87 return 0x0002245c;
88}
89static inline u32 top_slices_per_ltc_value_v(u32 r)
90{
91 return (r >> 0) & 0x1f;
92}
93static inline u32 top_num_ltcs_r(void)
94{
95 return 0x00022454;
96}
97static inline u32 top_device_info_r(u32 i)
98{
99 return 0x00022700 + i*4;
100}
101static inline u32 top_device_info__size_1_v(void)
102{
103 return 0x00000040;
104}
105static inline u32 top_device_info_chain_v(u32 r)
106{
107 return (r >> 31) & 0x1;
108}
109static inline u32 top_device_info_chain_enable_v(void)
110{
111 return 0x00000001;
112}
113static inline u32 top_device_info_engine_enum_v(u32 r)
114{
115 return (r >> 26) & 0xf;
116}
117static inline u32 top_device_info_runlist_enum_v(u32 r)
118{
119 return (r >> 21) & 0xf;
120}
121static inline u32 top_device_info_intr_enum_v(u32 r)
122{
123 return (r >> 15) & 0x1f;
124}
125static inline u32 top_device_info_reset_enum_v(u32 r)
126{
127 return (r >> 9) & 0x1f;
128}
129static inline u32 top_device_info_type_enum_v(u32 r)
130{
131 return (r >> 2) & 0x1fffffff;
132}
133static inline u32 top_device_info_type_enum_graphics_v(void)
134{
135 return 0x00000000;
136}
137static inline u32 top_device_info_type_enum_graphics_f(void)
138{
139 return 0x0;
140}
141static inline u32 top_device_info_type_enum_copy2_v(void)
142{
143 return 0x00000003;
144}
145static inline u32 top_device_info_type_enum_copy2_f(void)
146{
147 return 0xc;
148}
149static inline u32 top_device_info_type_enum_lce_v(void)
150{
151 return 0x00000013;
152}
153static inline u32 top_device_info_type_enum_lce_f(void)
154{
155 return 0x4c;
156}
157static inline u32 top_device_info_engine_v(u32 r)
158{
159 return (r >> 5) & 0x1;
160}
161static inline u32 top_device_info_runlist_v(u32 r)
162{
163 return (r >> 4) & 0x1;
164}
165static inline u32 top_device_info_intr_v(u32 r)
166{
167 return (r >> 3) & 0x1;
168}
169static inline u32 top_device_info_reset_v(u32 r)
170{
171 return (r >> 2) & 0x1;
172}
173static inline u32 top_device_info_entry_v(u32 r)
174{
175 return (r >> 0) & 0x3;
176}
177static inline u32 top_device_info_entry_not_valid_v(void)
178{
179 return 0x00000000;
180}
181static inline u32 top_device_info_entry_enum_v(void)
182{
183 return 0x00000002;
184}
185static inline u32 top_device_info_entry_engine_type_v(void)
186{
187 return 0x00000002;
188}
189static inline u32 top_device_info_entry_data_v(void)
190{
191 return 0x00000001;
192}
193static inline u32 top_device_info_data_type_v(u32 r)
194{
195 return (r >> 30) & 0x1;
196}
197static inline u32 top_device_info_data_type_enum2_v(void)
198{
199 return 0x00000000;
200}
201static inline u32 top_device_info_data_inst_id_v(u32 r)
202{
203 return (r >> 26) & 0xf;
204}
205static inline u32 top_device_info_data_pri_base_v(u32 r)
206{
207 return (r >> 12) & 0xfff;
208}
209static inline u32 top_device_info_data_pri_base_align_v(void)
210{
211 return 0x0000000c;
212}
213static inline u32 top_device_info_data_fault_id_enum_v(u32 r)
214{
215 return (r >> 3) & 0x1f;
216}
217static inline u32 top_device_info_data_fault_id_v(u32 r)
218{
219 return (r >> 2) & 0x1;
220}
221static inline u32 top_device_info_data_fault_id_valid_v(void)
222{
223 return 0x00000001;
224}
225#endif
diff --git a/drivers/gpu/nvgpu/gp10b/ltc_gp10b.c b/drivers/gpu/nvgpu/gp10b/ltc_gp10b.c
new file mode 100644
index 00000000..31c79aff
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/ltc_gp10b.c
@@ -0,0 +1,225 @@
1/*
2 * GP10B L2
3 *
4 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/types.h>
17
18#include <dt-bindings/memory/tegra-swgroup.h>
19
20#include "gk20a/gk20a.h"
21#include "gm20b/ltc_gm20b.h"
22#include "hw_mc_gp10b.h"
23#include "hw_ltc_gp10b.h"
24
25#include "gk20a/ltc_common.c"
26
27static int gp10b_determine_L2_size_bytes(struct gk20a *g)
28{
29 u32 tmp;
30 int ret;
31
32 gk20a_dbg_fn("");
33
34 tmp = gk20a_readl(g, ltc_ltc0_lts0_tstg_info_1_r());
35
36 ret = g->ltc_count *
37 ltc_ltc0_lts0_tstg_info_1_slice_size_in_kb_v(tmp)*1024 *
38 ltc_ltc0_lts0_tstg_info_1_slices_per_l2_v(tmp);
39
40 gk20a_dbg(gpu_dbg_info, "L2 size: %d\n", ret);
41
42 gk20a_dbg_fn("done");
43
44 return ret;
45}
46
47static int gp10b_ltc_init_comptags(struct gk20a *g, struct gr_gk20a *gr)
48{
49 /* max memory size (MB) to cover */
50 u32 max_size = gr->max_comptag_mem;
51 /* one tag line covers 64KB */
52 u32 max_comptag_lines = max_size << 4;
53
54 u32 hw_max_comptag_lines =
55 ltc_ltcs_ltss_cbc_ctrl3_clear_upper_bound_init_v();
56
57 u32 cbc_param =
58 gk20a_readl(g, ltc_ltcs_ltss_cbc_param_r());
59 u32 comptags_per_cacheline =
60 ltc_ltcs_ltss_cbc_param_comptags_per_cache_line_v(cbc_param);
61 u32 cacheline_size =
62 512 << ltc_ltcs_ltss_cbc_param_cache_line_size_v(cbc_param);
63 u32 slices_per_ltc =
64 ltc_ltcs_ltss_cbc_param_slices_per_ltc_v(cbc_param);
65 u32 cbc_param2 =
66 gk20a_readl(g, ltc_ltcs_ltss_cbc_param2_r());
67 u32 gobs_per_comptagline_per_slice =
68 ltc_ltcs_ltss_cbc_param2_gobs_per_comptagline_per_slice_v(cbc_param2);
69
70 u32 compbit_backing_size;
71
72 int err;
73 struct gk20a_platform *platform = dev_get_drvdata(g->dev);
74
75 gk20a_dbg_fn("");
76
77 if (max_comptag_lines == 0)
78 return 0;
79
80 if (max_comptag_lines > hw_max_comptag_lines)
81 max_comptag_lines = hw_max_comptag_lines;
82
83 compbit_backing_size =
84 roundup(max_comptag_lines * gobs_per_comptagline_per_slice,
85 cacheline_size);
86 compbit_backing_size =
87 roundup(compbit_backing_size * slices_per_ltc * g->ltc_count,
88 g->ops.fb.compressible_page_size(g));
89
90 /* aligned to 2KB * ltc_count */
91 compbit_backing_size +=
92 g->ltc_count << ltc_ltcs_ltss_cbc_base_alignment_shift_v();
93
94 /* must be a multiple of 64KB */
95 compbit_backing_size = roundup(compbit_backing_size, 64*1024);
96
97 gk20a_dbg_info("compbit backing store size : %d",
98 compbit_backing_size);
99 gk20a_dbg_info("max comptag lines : %d",
100 max_comptag_lines);
101 gk20a_dbg_info("gobs_per_comptagline_per_slice: %d",
102 gobs_per_comptagline_per_slice);
103
104 if (platform->is_fmodel)
105 err = gk20a_ltc_alloc_phys_cbc(g, compbit_backing_size);
106 else
107 err = gk20a_ltc_alloc_virt_cbc(g, compbit_backing_size);
108
109 if (err)
110 return err;
111
112 err = gk20a_comptag_allocator_init(&gr->comp_tags, max_comptag_lines);
113 if (err)
114 return err;
115
116 gr->comptags_per_cacheline = comptags_per_cacheline;
117 gr->slices_per_ltc = slices_per_ltc;
118 gr->cacheline_size = cacheline_size;
119 gr->gobs_per_comptagline_per_slice = gobs_per_comptagline_per_slice;
120
121 return 0;
122}
123
124static void gp10b_ltc_isr(struct gk20a *g)
125{
126 u32 mc_intr, ltc_intr;
127 unsigned int ltc, slice;
128 u32 ltc_stride = nvgpu_get_litter_value(g, GPU_LIT_LTC_STRIDE);
129 u32 lts_stride = nvgpu_get_litter_value(g, GPU_LIT_LTS_STRIDE);
130
131 mc_intr = gk20a_readl(g, mc_intr_ltc_r());
132 gk20a_err(dev_from_gk20a(g), "mc_ltc_intr: %08x",
133 mc_intr);
134 for (ltc = 0; ltc < g->ltc_count; ltc++) {
135 if ((mc_intr & 1 << ltc) == 0)
136 continue;
137 for (slice = 0; slice < g->gr.slices_per_ltc; slice++) {
138 u32 offset = ltc_stride * ltc + lts_stride * slice;
139 ltc_intr = gk20a_readl(g, ltc_ltc0_lts0_intr_r() + offset);
140
141 /* Detect and handle ECC errors */
142 if (ltc_intr &
143 ltc_ltcs_ltss_intr_ecc_sec_error_pending_f()) {
144 u32 ecc_stats_reg_val;
145
146 gk20a_err(dev_from_gk20a(g),
147 "Single bit error detected in GPU L2!");
148
149 ecc_stats_reg_val =
150 gk20a_readl(g,
151 ltc_ltc0_lts0_dstg_ecc_report_r() + offset);
152 g->gr.t18x.ecc_stats.l2_sec_count.counters[ltc] +=
153 ltc_ltc0_lts0_dstg_ecc_report_sec_count_v(ecc_stats_reg_val);
154 ecc_stats_reg_val &=
155 ~(ltc_ltc0_lts0_dstg_ecc_report_sec_count_m());
156 gk20a_writel(g,
157 ltc_ltc0_lts0_dstg_ecc_report_r() + offset,
158 ecc_stats_reg_val);
159
160 g->ops.mm.l2_flush(g, true);
161 }
162 if (ltc_intr &
163 ltc_ltcs_ltss_intr_ecc_ded_error_pending_f()) {
164 u32 ecc_stats_reg_val;
165
166 gk20a_err(dev_from_gk20a(g),
167 "Double bit error detected in GPU L2!");
168
169 ecc_stats_reg_val =
170 gk20a_readl(g,
171 ltc_ltc0_lts0_dstg_ecc_report_r() + offset);
172 g->gr.t18x.ecc_stats.l2_ded_count.counters[ltc] +=
173 ltc_ltc0_lts0_dstg_ecc_report_ded_count_v(ecc_stats_reg_val);
174 ecc_stats_reg_val &=
175 ~(ltc_ltc0_lts0_dstg_ecc_report_ded_count_m());
176 gk20a_writel(g,
177 ltc_ltc0_lts0_dstg_ecc_report_r() + offset,
178 ecc_stats_reg_val);
179 }
180
181 gk20a_err(dev_from_gk20a(g), "ltc%d, slice %d: %08x",
182 ltc, slice, ltc_intr);
183 gk20a_writel(g, ltc_ltc0_lts0_intr_r() +
184 ltc_stride * ltc + lts_stride * slice,
185 ltc_intr);
186 }
187 }
188}
189
190static void gp10b_ltc_init_fs_state(struct gk20a *g)
191{
192 u32 ltc_intr;
193
194 gm20b_ltc_init_fs_state(g);
195
196 gk20a_writel(g, ltc_ltca_g_axi_pctrl_r(),
197 ltc_ltca_g_axi_pctrl_user_sid_f(TEGRA_SID_GPUB));
198
199 /* Enable ECC interrupts */
200 ltc_intr = gk20a_readl(g, ltc_ltcs_ltss_intr_r());
201 ltc_intr |= ltc_ltcs_ltss_intr_en_ecc_sec_error_enabled_f() |
202 ltc_ltcs_ltss_intr_en_ecc_ded_error_enabled_f();
203 gk20a_writel(g, ltc_ltcs_ltss_intr_r(),
204 ltc_intr);
205}
206
207void gp10b_init_ltc(struct gpu_ops *gops)
208{
209 gops->ltc.determine_L2_size_bytes = gp10b_determine_L2_size_bytes;
210 gops->ltc.set_zbc_color_entry = gk20a_ltc_set_zbc_color_entry;
211 gops->ltc.set_zbc_depth_entry = gk20a_ltc_set_zbc_depth_entry;
212 gops->ltc.init_cbc = gk20a_ltc_init_cbc;
213
214 /* GM20b specific ops. */
215 gops->ltc.init_fs_state = gp10b_ltc_init_fs_state;
216 gops->ltc.init_comptags = gp10b_ltc_init_comptags;
217 gops->ltc.cbc_ctrl = gm20b_ltc_cbc_ctrl;
218 gops->ltc.elpg_flush = gm20b_ltc_g_elpg_flush_locked;
219 gops->ltc.isr = gp10b_ltc_isr;
220 gops->ltc.cbc_fix_config = gm20b_ltc_cbc_fix_config;
221 gops->ltc.flush = gm20b_flush_ltc;
222#ifdef CONFIG_DEBUG_FS
223 gops->ltc.sync_debugfs = gk20a_ltc_sync_debugfs;
224#endif
225}
diff --git a/drivers/gpu/nvgpu/gp10b/ltc_gp10b.h b/drivers/gpu/nvgpu/gp10b/ltc_gp10b.h
new file mode 100644
index 00000000..7408348e
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/ltc_gp10b.h
@@ -0,0 +1,19 @@
1/*
2 * Copyright (c) 2014, 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
14#ifndef LTC_GP10B_H
15#define LTC_GP10B_H
16struct gpu_ops;
17
18void gp10b_init_ltc(struct gpu_ops *gops);
19#endif
diff --git a/drivers/gpu/nvgpu/gp10b/mc_gp10b.c b/drivers/gpu/nvgpu/gp10b/mc_gp10b.c
new file mode 100644
index 00000000..eda961b6
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/mc_gp10b.c
@@ -0,0 +1,202 @@
1/*
2 * GP20B master
3 *
4 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/types.h>
17
18#include "gk20a/gk20a.h"
19#include "mc_gp10b.h"
20#include "hw_mc_gp10b.h"
21
22void mc_gp10b_intr_enable(struct gk20a *g)
23{
24 u32 eng_intr_mask = gk20a_fifo_engine_interrupt_mask(g);
25
26 gk20a_writel(g, mc_intr_en_clear_r(NVGPU_MC_INTR_STALLING),
27 0xffffffff);
28 g->ops.mc.intr_mask_restore[NVGPU_MC_INTR_STALLING] =
29 mc_intr_pfifo_pending_f()
30 | mc_intr_replayable_fault_pending_f()
31 | eng_intr_mask;
32 gk20a_writel(g, mc_intr_en_set_r(NVGPU_MC_INTR_STALLING),
33 g->ops.mc.intr_mask_restore[NVGPU_MC_INTR_STALLING]);
34
35 gk20a_writel(g, mc_intr_en_clear_r(NVGPU_MC_INTR_NONSTALLING),
36 0xffffffff);
37 g->ops.mc.intr_mask_restore[NVGPU_MC_INTR_NONSTALLING] =
38 mc_intr_pfifo_pending_f()
39 | mc_intr_priv_ring_pending_f()
40 | mc_intr_ltc_pending_f()
41 | mc_intr_pbus_pending_f()
42 | eng_intr_mask;
43 gk20a_writel(g, mc_intr_en_set_r(NVGPU_MC_INTR_NONSTALLING),
44 g->ops.mc.intr_mask_restore[NVGPU_MC_INTR_NONSTALLING]);
45}
46
47void mc_gp10b_intr_unit_config(struct gk20a *g, bool enable,
48 bool is_stalling, u32 mask)
49{
50 u32 intr_index = 0;
51 u32 reg = 0;
52
53 intr_index = (is_stalling ? NVGPU_MC_INTR_STALLING :
54 NVGPU_MC_INTR_NONSTALLING);
55 if (enable) {
56 reg = mc_intr_en_set_r(intr_index);
57 g->ops.mc.intr_mask_restore[intr_index] |= mask;
58
59 } else {
60 reg = mc_intr_en_clear_r(intr_index);
61 g->ops.mc.intr_mask_restore[intr_index] &= ~mask;
62 }
63
64 gk20a_writel(g, reg, mask);
65}
66
67irqreturn_t mc_gp10b_isr_stall(struct gk20a *g)
68{
69 u32 mc_intr_0;
70
71 if (!g->power_on)
72 return IRQ_NONE;
73
74 /* not from gpu when sharing irq with others */
75 mc_intr_0 = gk20a_readl(g, mc_intr_r(0));
76 if (unlikely(!mc_intr_0))
77 return IRQ_NONE;
78
79 gk20a_writel(g, mc_intr_en_clear_r(0), 0xffffffff);
80
81 return IRQ_WAKE_THREAD;
82}
83
84irqreturn_t mc_gp10b_isr_nonstall(struct gk20a *g)
85{
86 u32 mc_intr_1;
87
88 if (!g->power_on)
89 return IRQ_NONE;
90
91 /* not from gpu when sharing irq with others */
92 mc_intr_1 = gk20a_readl(g, mc_intr_r(1));
93 if (unlikely(!mc_intr_1))
94 return IRQ_NONE;
95
96 gk20a_writel(g, mc_intr_en_clear_r(1), 0xffffffff);
97
98 return IRQ_WAKE_THREAD;
99}
100
101irqreturn_t mc_gp10b_intr_thread_stall(struct gk20a *g)
102{
103 u32 mc_intr_0;
104 u32 engine_id_idx;
105 u32 active_engine_id = 0;
106 u32 engine_enum = ENGINE_INVAL_GK20A;
107
108 gk20a_dbg(gpu_dbg_intr, "interrupt thread launched");
109
110 mc_intr_0 = gk20a_readl(g, mc_intr_r(0));
111
112 gk20a_dbg(gpu_dbg_intr, "stall intr %08x\n", mc_intr_0);
113
114 for (engine_id_idx = 0; engine_id_idx < g->fifo.num_engines; engine_id_idx++) {
115 active_engine_id = g->fifo.active_engines_list[engine_id_idx];
116
117 if (mc_intr_0 & g->fifo.engine_info[active_engine_id].intr_mask) {
118 engine_enum = g->fifo.engine_info[active_engine_id].engine_enum;
119 /* GR Engine */
120 if (engine_enum == ENGINE_GR_GK20A) {
121 gr_gk20a_elpg_protected_call(g, gk20a_gr_isr(g));
122 }
123
124 /* CE Engine */
125 if (((engine_enum == ENGINE_GRCE_GK20A) ||
126 (engine_enum == ENGINE_ASYNC_CE_GK20A)) &&
127 g->ops.ce2.isr_stall){
128 g->ops.ce2.isr_stall(g,
129 g->fifo.engine_info[active_engine_id].inst_id,
130 g->fifo.engine_info[active_engine_id].pri_base);
131 }
132 }
133 }
134 if (mc_intr_0 & mc_intr_pfifo_pending_f())
135 gk20a_fifo_isr(g);
136 if (mc_intr_0 & mc_intr_pmu_pending_f())
137 gk20a_pmu_isr(g);
138 if (mc_intr_0 & mc_intr_priv_ring_pending_f())
139 gk20a_priv_ring_isr(g);
140 if (mc_intr_0 & mc_intr_ltc_pending_f())
141 g->ops.ltc.isr(g);
142 if (mc_intr_0 & mc_intr_pbus_pending_f())
143 gk20a_pbus_isr(g);
144
145 gk20a_writel(g, mc_intr_en_set_r(NVGPU_MC_INTR_STALLING),
146 g->ops.mc.intr_mask_restore[NVGPU_MC_INTR_STALLING]);
147
148 return IRQ_HANDLED;
149}
150
151irqreturn_t mc_gp10b_intr_thread_nonstall(struct gk20a *g)
152{
153 u32 mc_intr_1;
154 u32 engine_id_idx;
155 u32 active_engine_id = 0;
156 u32 engine_enum = ENGINE_INVAL_GK20A;
157
158 gk20a_dbg(gpu_dbg_intr, "interrupt thread launched");
159
160 mc_intr_1 = gk20a_readl(g, mc_intr_r(1));
161
162 gk20a_dbg(gpu_dbg_intr, "non-stall intr %08x\n", mc_intr_1);
163
164 if (mc_intr_1 & mc_intr_pfifo_pending_f())
165 gk20a_fifo_nonstall_isr(g);
166
167 for (engine_id_idx = 0; engine_id_idx < g->fifo.num_engines; engine_id_idx++) {
168 active_engine_id = g->fifo.active_engines_list[engine_id_idx];
169
170 if (mc_intr_1 & g->fifo.engine_info[active_engine_id].intr_mask) {
171 engine_enum = g->fifo.engine_info[active_engine_id].engine_enum;
172 /* GR Engine */
173 if (engine_enum == ENGINE_GR_GK20A) {
174 gk20a_gr_nonstall_isr(g);
175 }
176
177 /* CE Engine */
178 if (((engine_enum == ENGINE_GRCE_GK20A) ||
179 (engine_enum == ENGINE_ASYNC_CE_GK20A)) &&
180 g->ops.ce2.isr_nonstall) {
181 g->ops.ce2.isr_nonstall(g,
182 g->fifo.engine_info[active_engine_id].inst_id,
183 g->fifo.engine_info[active_engine_id].pri_base);
184 }
185 }
186 }
187
188 gk20a_writel(g, mc_intr_en_set_r(NVGPU_MC_INTR_NONSTALLING),
189 g->ops.mc.intr_mask_restore[NVGPU_MC_INTR_NONSTALLING]);
190
191 return IRQ_HANDLED;
192}
193
194void gp10b_init_mc(struct gpu_ops *gops)
195{
196 gops->mc.intr_enable = mc_gp10b_intr_enable;
197 gops->mc.intr_unit_config = mc_gp10b_intr_unit_config;
198 gops->mc.isr_stall = mc_gp10b_isr_stall;
199 gops->mc.isr_nonstall = mc_gp10b_isr_nonstall;
200 gops->mc.isr_thread_stall = mc_gp10b_intr_thread_stall;
201 gops->mc.isr_thread_nonstall = mc_gp10b_intr_thread_nonstall;
202}
diff --git a/drivers/gpu/nvgpu/gp10b/mc_gp10b.h b/drivers/gpu/nvgpu/gp10b/mc_gp10b.h
new file mode 100644
index 00000000..b2ec4be4
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/mc_gp10b.h
@@ -0,0 +1,31 @@
1/*
2 * Copyright (c) 2014, 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
14#ifndef MC_GP20B_H
15#define MC_GP20B_H
16struct gk20a;
17
18enum MC_INTERRUPT_REGLIST {
19 NVGPU_MC_INTR_STALLING = 0,
20 NVGPU_MC_INTR_NONSTALLING,
21};
22
23void gp10b_init_mc(struct gpu_ops *gops);
24void mc_gp10b_intr_enable(struct gk20a *g);
25void mc_gp10b_intr_unit_config(struct gk20a *g, bool enable,
26 bool is_stalling, u32 mask);
27irqreturn_t mc_gp10b_isr_stall(struct gk20a *g);
28irqreturn_t mc_gp10b_isr_nonstall(struct gk20a *g);
29irqreturn_t mc_gp10b_intr_thread_stall(struct gk20a *g);
30irqreturn_t mc_gp10b_intr_thread_nonstall(struct gk20a *g);
31#endif
diff --git a/drivers/gpu/nvgpu/gp10b/mm_gp10b.c b/drivers/gpu/nvgpu/gp10b/mm_gp10b.c
new file mode 100644
index 00000000..1b6b6641
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/mm_gp10b.c
@@ -0,0 +1,417 @@
1/*
2 * GP10B MMU
3 *
4 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/pm_runtime.h>
17#include <linux/dma-mapping.h>
18#include "gk20a/gk20a.h"
19#include "mm_gp10b.h"
20#include "rpfb_gp10b.h"
21#include "hw_fb_gp10b.h"
22#include "hw_ram_gp10b.h"
23#include "hw_bus_gp10b.h"
24#include "hw_gmmu_gp10b.h"
25#include "gk20a/semaphore_gk20a.h"
26
27static u32 gp10b_mm_get_physical_addr_bits(struct gk20a *g)
28{
29 return 36;
30}
31
32static int gp10b_init_mm_setup_hw(struct gk20a *g)
33{
34 struct mm_gk20a *mm = &g->mm;
35 struct mem_desc *inst_block = &mm->bar1.inst_block;
36 int err = 0;
37
38 gk20a_dbg_fn("");
39
40 g->ops.fb.set_mmu_page_size(g);
41
42 gk20a_writel(g, fb_niso_flush_sysmem_addr_r(),
43 (g->ops.mm.get_iova_addr(g, g->mm.sysmem_flush.sgt->sgl, 0)
44 >> 8ULL));
45
46 g->ops.mm.bar1_bind(g, inst_block);
47
48 if (g->ops.mm.init_bar2_mm_hw_setup) {
49 err = g->ops.mm.init_bar2_mm_hw_setup(g);
50 if (err)
51 return err;
52 }
53
54 if (gk20a_mm_fb_flush(g) || gk20a_mm_fb_flush(g))
55 return -EBUSY;
56
57 err = gp10b_replayable_pagefault_buffer_init(g);
58
59 gk20a_dbg_fn("done");
60 return err;
61
62}
63
64static int gb10b_init_bar2_vm(struct gk20a *g)
65{
66 int err;
67 struct mm_gk20a *mm = &g->mm;
68 struct vm_gk20a *vm = &mm->bar2.vm;
69 struct mem_desc *inst_block = &mm->bar2.inst_block;
70 u32 big_page_size = gk20a_get_platform(g->dev)->default_big_page_size;
71
72 /* BAR2 aperture size is 32MB */
73 mm->bar2.aperture_size = 32 << 20;
74 gk20a_dbg_info("bar2 vm size = 0x%x", mm->bar2.aperture_size);
75 gk20a_init_vm(mm, vm, big_page_size, SZ_4K,
76 mm->bar2.aperture_size - SZ_4K,
77 mm->bar2.aperture_size, false, false, "bar2");
78
79 /* allocate instance mem for bar2 */
80 err = gk20a_alloc_inst_block(g, inst_block);
81 if (err)
82 goto clean_up_va;
83
84 g->ops.mm.init_inst_block(inst_block, vm, big_page_size);
85
86 return 0;
87
88clean_up_va:
89 gk20a_deinit_vm(vm);
90 return err;
91}
92
93
94static int gb10b_init_bar2_mm_hw_setup(struct gk20a *g)
95{
96 struct mm_gk20a *mm = &g->mm;
97 struct mem_desc *inst_block = &mm->bar2.inst_block;
98 u64 inst_pa = gk20a_mm_inst_block_addr(g, inst_block);
99
100 gk20a_dbg_fn("");
101
102 g->ops.fb.set_mmu_page_size(g);
103
104 inst_pa = (u32)(inst_pa >> bus_bar2_block_ptr_shift_v());
105 gk20a_dbg_info("bar2 inst block ptr: 0x%08x", (u32)inst_pa);
106
107 gk20a_writel(g, bus_bar2_block_r(),
108 gk20a_aperture_mask(g, inst_block,
109 bus_bar2_block_target_sys_mem_ncoh_f(),
110 bus_bar2_block_target_vid_mem_f()) |
111 bus_bar2_block_mode_virtual_f() |
112 bus_bar2_block_ptr_f(inst_pa));
113
114 gk20a_dbg_fn("done");
115 return 0;
116}
117
118static u64 gp10b_mm_phys_addr_translate(struct gk20a *g, u64 phys_addr,
119 u32 flags)
120{
121 if (!device_is_iommuable(dev_from_gk20a(g)))
122 if (flags & NVGPU_AS_MAP_BUFFER_FLAGS_IO_COHERENT)
123 return phys_addr |
124 1ULL << NVGPU_MM_GET_IO_COHERENCE_BIT;
125
126 return phys_addr;
127}
128
129static u64 gp10b_mm_iova_addr(struct gk20a *g, struct scatterlist *sgl,
130 u32 flags)
131{
132 if (!device_is_iommuable(dev_from_gk20a(g)))
133 return gp10b_mm_phys_addr_translate(g, sg_phys(sgl), flags);
134
135 if (sg_dma_address(sgl) == 0)
136 return gp10b_mm_phys_addr_translate(g, sg_phys(sgl), flags);
137
138 if (sg_dma_address(sgl) == DMA_ERROR_CODE)
139 return 0;
140
141 return gk20a_mm_smmu_vaddr_translate(g, sg_dma_address(sgl));
142}
143
144static u32 pde3_from_index(u32 i)
145{
146 return i * gmmu_new_pde__size_v() / sizeof(u32);
147}
148
149static u32 pte3_from_index(u32 i)
150{
151 return i * gmmu_new_pte__size_v() / sizeof(u32);
152}
153
154static int update_gmmu_pde3_locked(struct vm_gk20a *vm,
155 struct gk20a_mm_entry *parent,
156 u32 i, u32 gmmu_pgsz_idx,
157 struct scatterlist **sgl,
158 u64 *offset,
159 u64 *iova,
160 u32 kind_v, u64 *ctag,
161 bool cacheable, bool unmapped_pte,
162 int rw_flag, bool sparse, bool priv,
163 enum gk20a_aperture aperture)
164{
165 struct gk20a *g = gk20a_from_vm(vm);
166 u64 pte_addr = 0;
167 struct gk20a_mm_entry *pte = parent->entries + i;
168 u32 pde_v[2] = {0, 0};
169 u32 pde;
170
171 gk20a_dbg_fn("");
172
173 pte_addr = gk20a_pde_addr(g, pte) >> gmmu_new_pde_address_shift_v();
174
175 pde_v[0] |= gk20a_aperture_mask(g, &pte->mem,
176 gmmu_new_pde_aperture_sys_mem_ncoh_f(),
177 gmmu_new_pde_aperture_video_memory_f());
178 pde_v[0] |= gmmu_new_pde_address_sys_f(u64_lo32(pte_addr));
179 pde_v[0] |= gmmu_new_pde_vol_true_f();
180 pde_v[1] |= pte_addr >> 24;
181 pde = pde3_from_index(i);
182
183 gk20a_pde_wr32(g, parent, pde + 0, pde_v[0]);
184 gk20a_pde_wr32(g, parent, pde + 1, pde_v[1]);
185
186 gk20a_dbg(gpu_dbg_pte, "pde:%d,sz=%d = 0x%x,0x%08x",
187 i, gmmu_pgsz_idx, pde_v[1], pde_v[0]);
188 gk20a_dbg_fn("done");
189 return 0;
190}
191
192static u32 pde0_from_index(u32 i)
193{
194 return i * gmmu_new_dual_pde__size_v() / sizeof(u32);
195}
196
197static int update_gmmu_pde0_locked(struct vm_gk20a *vm,
198 struct gk20a_mm_entry *pte,
199 u32 i, u32 gmmu_pgsz_idx,
200 struct scatterlist **sgl,
201 u64 *offset,
202 u64 *iova,
203 u32 kind_v, u64 *ctag,
204 bool cacheable, bool unmapped_pte,
205 int rw_flag, bool sparse, bool priv,
206 enum gk20a_aperture aperture)
207{
208 struct gk20a *g = gk20a_from_vm(vm);
209 bool small_valid, big_valid;
210 u32 pte_addr_small = 0, pte_addr_big = 0;
211 struct gk20a_mm_entry *entry = pte->entries + i;
212 u32 pde_v[4] = {0, 0, 0, 0};
213 u32 pde;
214
215 gk20a_dbg_fn("");
216
217 small_valid = entry->mem.size && entry->pgsz == gmmu_page_size_small;
218 big_valid = entry->mem.size && entry->pgsz == gmmu_page_size_big;
219
220 if (small_valid) {
221 pte_addr_small = gk20a_pde_addr(g, entry)
222 >> gmmu_new_dual_pde_address_shift_v();
223 }
224
225 if (big_valid)
226 pte_addr_big = gk20a_pde_addr(g, entry)
227 >> gmmu_new_dual_pde_address_big_shift_v();
228
229 if (small_valid) {
230 pde_v[2] |= gmmu_new_dual_pde_address_small_sys_f(pte_addr_small);
231 pde_v[2] |= gk20a_aperture_mask(g, &entry->mem,
232 gmmu_new_dual_pde_aperture_small_sys_mem_ncoh_f(),
233 gmmu_new_dual_pde_aperture_small_video_memory_f());
234 pde_v[2] |= gmmu_new_dual_pde_vol_small_true_f();
235 pde_v[3] |= pte_addr_small >> 24;
236 }
237
238 if (big_valid) {
239 pde_v[0] |= gmmu_new_dual_pde_address_big_sys_f(pte_addr_big);
240 pde_v[0] |= gmmu_new_dual_pde_vol_big_true_f();
241 pde_v[0] |= gk20a_aperture_mask(g, &entry->mem,
242 gmmu_new_dual_pde_aperture_big_sys_mem_ncoh_f(),
243 gmmu_new_dual_pde_aperture_big_video_memory_f());
244 pde_v[1] |= pte_addr_big >> 28;
245 }
246
247 pde = pde0_from_index(i);
248
249 gk20a_pde_wr32(g, pte, pde + 0, pde_v[0]);
250 gk20a_pde_wr32(g, pte, pde + 1, pde_v[1]);
251 gk20a_pde_wr32(g, pte, pde + 2, pde_v[2]);
252 gk20a_pde_wr32(g, pte, pde + 3, pde_v[3]);
253
254 gk20a_dbg(gpu_dbg_pte, "pde:%d,sz=%d [0x%08x, 0x%08x, 0x%x, 0x%08x]",
255 i, gmmu_pgsz_idx, pde_v[3], pde_v[2], pde_v[1], pde_v[0]);
256 gk20a_dbg_fn("done");
257 return 0;
258}
259
260static int update_gmmu_pte_locked(struct vm_gk20a *vm,
261 struct gk20a_mm_entry *pte,
262 u32 i, u32 gmmu_pgsz_idx,
263 struct scatterlist **sgl,
264 u64 *offset,
265 u64 *iova,
266 u32 kind_v, u64 *ctag,
267 bool cacheable, bool unmapped_pte,
268 int rw_flag, bool sparse, bool priv,
269 enum gk20a_aperture aperture)
270{
271 struct gk20a *g = vm->mm->g;
272 u32 page_size = vm->gmmu_page_sizes[gmmu_pgsz_idx];
273 u64 ctag_granularity = g->ops.fb.compression_page_size(g);
274 u32 pte_w[2] = {0, 0}; /* invalid pte */
275 u32 pte_i;
276
277 if (*iova) {
278 u32 pte_valid = unmapped_pte ?
279 gmmu_new_pte_valid_false_f() :
280 gmmu_new_pte_valid_true_f();
281 u32 iova_v = *iova >> gmmu_new_pte_address_shift_v();
282 u32 pte_addr = aperture == APERTURE_SYSMEM ?
283 gmmu_new_pte_address_sys_f(iova_v) :
284 gmmu_new_pte_address_vid_f(iova_v);
285 u32 pte_tgt = __gk20a_aperture_mask(g, aperture,
286 gmmu_new_pte_aperture_sys_mem_ncoh_f(),
287 gmmu_new_pte_aperture_video_memory_f());
288
289 pte_w[0] = pte_valid | pte_addr | pte_tgt;
290
291 if (priv)
292 pte_w[0] |= gmmu_new_pte_privilege_true_f();
293
294 pte_w[1] = *iova >> (24 + gmmu_new_pte_address_shift_v()) |
295 gmmu_new_pte_kind_f(kind_v) |
296 gmmu_new_pte_comptagline_f((u32)(*ctag / ctag_granularity));
297
298 if (rw_flag == gk20a_mem_flag_read_only)
299 pte_w[0] |= gmmu_new_pte_read_only_true_f();
300 if (unmapped_pte && !cacheable)
301 pte_w[0] |= gmmu_new_pte_read_only_true_f();
302 else if (!cacheable)
303 pte_w[0] |= gmmu_new_pte_vol_true_f();
304
305 gk20a_dbg(gpu_dbg_pte, "pte=%d iova=0x%llx kind=%d"
306 " ctag=%d vol=%d"
307 " [0x%08x, 0x%08x]",
308 i, *iova,
309 kind_v, (u32)(*ctag / ctag_granularity), !cacheable,
310 pte_w[1], pte_w[0]);
311
312 if (*ctag)
313 *ctag += page_size;
314 } else if (sparse) {
315 pte_w[0] = gmmu_new_pte_valid_false_f();
316 pte_w[0] |= gmmu_new_pte_vol_true_f();
317 } else {
318 gk20a_dbg(gpu_dbg_pte, "pte_cur=%d [0x0,0x0]", i);
319 }
320
321 pte_i = pte3_from_index(i);
322
323 gk20a_pde_wr32(g, pte, pte_i + 0, pte_w[0]);
324 gk20a_pde_wr32(g, pte, pte_i + 1, pte_w[1]);
325
326 if (*iova) {
327 *iova += page_size;
328 *offset += page_size;
329 if (*sgl && *offset + page_size > (*sgl)->length) {
330 u64 new_iova;
331 *sgl = sg_next(*sgl);
332 if (*sgl) {
333 new_iova = sg_phys(*sgl);
334 gk20a_dbg(gpu_dbg_pte, "chunk address %llx, size %d",
335 new_iova, (*sgl)->length);
336 if (new_iova) {
337 *offset = 0;
338 *iova = new_iova;
339 }
340 }
341 }
342 }
343 return 0;
344}
345
346static const struct gk20a_mmu_level gp10b_mm_levels[] = {
347 {.hi_bit = {48, 48},
348 .lo_bit = {47, 47},
349 .update_entry = update_gmmu_pde3_locked,
350 .entry_size = 8},
351 {.hi_bit = {46, 46},
352 .lo_bit = {38, 38},
353 .update_entry = update_gmmu_pde3_locked,
354 .entry_size = 8},
355 {.hi_bit = {37, 37},
356 .lo_bit = {29, 29},
357 .update_entry = update_gmmu_pde3_locked,
358 .entry_size = 8},
359 {.hi_bit = {28, 28},
360 .lo_bit = {21, 21},
361 .update_entry = update_gmmu_pde0_locked,
362 .entry_size = 16},
363 {.hi_bit = {20, 20},
364 .lo_bit = {12, 16},
365 .update_entry = update_gmmu_pte_locked,
366 .entry_size = 8},
367 {.update_entry = NULL}
368};
369
370static const struct gk20a_mmu_level *gp10b_mm_get_mmu_levels(struct gk20a *g,
371 u32 big_page_size)
372{
373 return gp10b_mm_levels;
374}
375
376static void gp10b_mm_init_pdb(struct gk20a *g, struct mem_desc *inst_block,
377 struct vm_gk20a *vm)
378{
379 u64 pdb_addr = gk20a_mem_get_base_addr(g, &vm->pdb.mem, 0);
380 u32 pdb_addr_lo = u64_lo32(pdb_addr >> ram_in_base_shift_v());
381 u32 pdb_addr_hi = u64_hi32(pdb_addr);
382
383 gk20a_dbg_info("pde pa=0x%llx", pdb_addr);
384
385 gk20a_mem_wr32(g, inst_block, ram_in_page_dir_base_lo_w(),
386 gk20a_aperture_mask(g, &vm->pdb.mem,
387 ram_in_page_dir_base_target_sys_mem_ncoh_f(),
388 ram_in_page_dir_base_target_vid_mem_f()) |
389 ram_in_page_dir_base_vol_true_f() |
390 ram_in_page_dir_base_lo_f(pdb_addr_lo) |
391 1 << 10);
392
393 gk20a_mem_wr32(g, inst_block, ram_in_page_dir_base_hi_w(),
394 ram_in_page_dir_base_hi_f(pdb_addr_hi));
395}
396
397static void gp10b_remove_bar2_vm(struct gk20a *g)
398{
399 struct mm_gk20a *mm = &g->mm;
400
401 gp10b_replayable_pagefault_buffer_deinit(g);
402 gk20a_remove_vm(&mm->bar2.vm, &mm->bar2.inst_block);
403}
404
405
406void gp10b_init_mm(struct gpu_ops *gops)
407{
408 gm20b_init_mm(gops);
409 gops->mm.get_physical_addr_bits = gp10b_mm_get_physical_addr_bits;
410 gops->mm.init_mm_setup_hw = gp10b_init_mm_setup_hw;
411 gops->mm.init_bar2_vm = gb10b_init_bar2_vm;
412 gops->mm.init_bar2_mm_hw_setup = gb10b_init_bar2_mm_hw_setup;
413 gops->mm.get_iova_addr = gp10b_mm_iova_addr;
414 gops->mm.get_mmu_levels = gp10b_mm_get_mmu_levels;
415 gops->mm.init_pdb = gp10b_mm_init_pdb;
416 gops->mm.remove_bar2_vm = gp10b_remove_bar2_vm;
417}
diff --git a/drivers/gpu/nvgpu/gp10b/mm_gp10b.h b/drivers/gpu/nvgpu/gp10b/mm_gp10b.h
new file mode 100644
index 00000000..034944e0
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/mm_gp10b.h
@@ -0,0 +1,22 @@
1/*
2 * Copyright (c) 2014, 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
14#ifndef MM_GP10B_H
15#define MM_GP10B_H
16
17#define NVGPU_MM_GET_IO_COHERENCE_BIT 35
18
19struct gpu_ops;
20
21void gp10b_init_mm(struct gpu_ops *gops);
22#endif
diff --git a/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c
new file mode 100644
index 00000000..8cf6d5e8
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/platform_gp10b_tegra.c
@@ -0,0 +1,751 @@
1/*
2 * GP10B Tegra Platform Interface
3 *
4 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/of_platform.h>
17#include <linux/nvhost.h>
18#include <linux/debugfs.h>
19#include <linux/tegra-powergate.h>
20#include <linux/platform_data/tegra_edp.h>
21#include <uapi/linux/nvgpu.h>
22#include <linux/dma-buf.h>
23#include <linux/nvmap.h>
24#include <linux/reset.h>
25#include <soc/tegra/tegra_bpmp.h>
26#include <linux/hashtable.h>
27#include "gk20a/platform_gk20a.h"
28#include "gk20a/gk20a.h"
29#include "gk20a/gk20a_scale.h"
30#include "platform_tegra.h"
31#include "gr_gp10b.h"
32#include "ltc_gp10b.h"
33#include "hw_gr_gp10b.h"
34#include "hw_ltc_gp10b.h"
35#include "gp10b_sysfs.h"
36#include <linux/platform/tegra/emc_bwmgr.h>
37
38#define GP10B_MAX_SUPPORTED_FREQS 11
39static unsigned long gp10b_freq_table[GP10B_MAX_SUPPORTED_FREQS];
40
41#define TEGRA_GP10B_BW_PER_FREQ 64
42#define TEGRA_DDR4_BW_PER_FREQ 16
43
44#define EMC_BW_RATIO (TEGRA_GP10B_BW_PER_FREQ / TEGRA_DDR4_BW_PER_FREQ)
45
46static struct {
47 char *name;
48 unsigned long default_rate;
49} tegra_gp10b_clocks[] = {
50 {"gpu", 1000000000},
51 {"gpu_sys", 204000000} };
52
53static void gr_gp10b_remove_sysfs(struct device *dev);
54
55/*
56 * gp10b_tegra_get_clocks()
57 *
58 * This function finds clocks in tegra platform and populates
59 * the clock information to gp10b platform data.
60 */
61
62static int gp10b_tegra_get_clocks(struct device *dev)
63{
64 struct gk20a_platform *platform = dev_get_drvdata(dev);
65 unsigned int i;
66
67 if (platform->is_fmodel)
68 return 0;
69
70 platform->num_clks = 0;
71 for (i = 0; i < ARRAY_SIZE(tegra_gp10b_clocks); i++) {
72 long rate = tegra_gp10b_clocks[i].default_rate;
73 struct clk *c;
74
75 c = clk_get(dev, tegra_gp10b_clocks[i].name);
76 if (IS_ERR(c)) {
77 gk20a_err(dev, "cannot get clock %s",
78 tegra_gp10b_clocks[i].name);
79 } else {
80 clk_set_rate(c, rate);
81 platform->clk[i] = c;
82 }
83 }
84 platform->num_clks = i;
85
86 return 0;
87}
88
89static void gp10b_tegra_scale_init(struct device *dev)
90{
91 struct gk20a_platform *platform = gk20a_get_platform(dev);
92 struct gk20a_scale_profile *profile = platform->g->scale_profile;
93 struct tegra_bwmgr_client *bwmgr_handle;
94
95 if (!profile)
96 return;
97
98 bwmgr_handle = tegra_bwmgr_register(TEGRA_BWMGR_CLIENT_GPU);
99 if (!bwmgr_handle)
100 return;
101
102 profile->private_data = (void *)bwmgr_handle;
103}
104
105static void gp10b_tegra_scale_exit(struct device *dev)
106{
107 struct gk20a_platform *platform = gk20a_get_platform(dev);
108 struct gk20a_scale_profile *profile = platform->g->scale_profile;
109
110 if (profile)
111 tegra_bwmgr_unregister(
112 (struct tegra_bwmgr_client *)profile->private_data);
113}
114
115static int gp10b_tegra_probe(struct device *dev)
116{
117 struct gk20a_platform *platform = dev_get_drvdata(dev);
118 struct device_node *np = dev->of_node;
119 struct device_node *host1x_node;
120 struct platform_device *host1x_pdev;
121 const __be32 *host1x_ptr;
122
123 host1x_ptr = of_get_property(np, "nvidia,host1x", NULL);
124 if (!host1x_ptr) {
125 gk20a_err(dev, "host1x device not available");
126 return -ENOSYS;
127 }
128
129 host1x_node = of_find_node_by_phandle(be32_to_cpup(host1x_ptr));
130 host1x_pdev = of_find_device_by_node(host1x_node);
131 if (!host1x_pdev) {
132 gk20a_err(dev, "host1x device not available");
133 return -ENOSYS;
134 }
135
136 platform->g->host1x_dev = host1x_pdev;
137 platform->bypass_smmu = !device_is_iommuable(dev);
138 platform->disable_bigpage = platform->bypass_smmu;
139
140 platform->g->gr.t18x.ctx_vars.dump_ctxsw_stats_on_channel_close
141 = false;
142 platform->g->gr.t18x.ctx_vars.dump_ctxsw_stats_on_channel_close
143 = false;
144
145 platform->g->gr.t18x.ctx_vars.force_preemption_gfxp = false;
146 platform->g->gr.t18x.ctx_vars.force_preemption_cilp = false;
147
148 platform->g->gr.t18x.ctx_vars.debugfs_force_preemption_gfxp =
149 debugfs_create_bool("force_preemption_gfxp", S_IRUGO|S_IWUSR,
150 platform->debugfs,
151 &platform->g->gr.t18x.ctx_vars.force_preemption_gfxp);
152
153 platform->g->gr.t18x.ctx_vars.debugfs_force_preemption_cilp =
154 debugfs_create_bool("force_preemption_cilp", S_IRUGO|S_IWUSR,
155 platform->debugfs,
156 &platform->g->gr.t18x.ctx_vars.force_preemption_cilp);
157
158 platform->g->gr.t18x.ctx_vars.debugfs_dump_ctxsw_stats =
159 debugfs_create_bool("dump_ctxsw_stats_on_channel_close",
160 S_IRUGO|S_IWUSR,
161 platform->debugfs,
162 &platform->g->gr.t18x.
163 ctx_vars.dump_ctxsw_stats_on_channel_close);
164
165 platform->g->mm.vidmem_is_vidmem = platform->vidmem_is_vidmem;
166
167 gp10b_tegra_get_clocks(dev);
168
169 return 0;
170}
171
172static int gp10b_tegra_late_probe(struct device *dev)
173{
174 /*Create GP10B specific sysfs*/
175 gp10b_create_sysfs(dev);
176
177 /* Initialise tegra specific scaling quirks */
178 gp10b_tegra_scale_init(dev);
179 return 0;
180}
181
182static int gp10b_tegra_remove(struct device *dev)
183{
184 gr_gp10b_remove_sysfs(dev);
185 /*Remove GP10B specific sysfs*/
186 gp10b_remove_sysfs(dev);
187
188 /* deinitialise tegra specific scaling quirks */
189 gp10b_tegra_scale_exit(dev);
190
191 return 0;
192
193}
194
195static bool gp10b_tegra_is_railgated(struct device *dev)
196{
197 bool ret = false;
198
199 if (tegra_bpmp_running())
200 ret = !tegra_powergate_is_powered(TEGRA_POWERGATE_GPU);
201
202 return ret;
203}
204
205static int gp10b_tegra_railgate(struct device *dev)
206{
207 struct gk20a_platform *platform = gk20a_get_platform(dev);
208 struct gk20a_scale_profile *profile = platform->g->scale_profile;
209
210 /* remove emc frequency floor */
211 if (profile)
212 tegra_bwmgr_set_emc(
213 (struct tegra_bwmgr_client *)profile->private_data,
214 0, TEGRA_BWMGR_SET_EMC_FLOOR);
215
216 if (tegra_bpmp_running() &&
217 tegra_powergate_is_powered(TEGRA_POWERGATE_GPU)) {
218 int i;
219 for (i = 0; i < platform->num_clks; i++) {
220 if (platform->clk[i])
221 clk_disable_unprepare(platform->clk[i]);
222 }
223 tegra_powergate_partition(TEGRA_POWERGATE_GPU);
224 }
225 return 0;
226}
227
228static int gp10b_tegra_unrailgate(struct device *dev)
229{
230 int ret = 0;
231 struct gk20a_platform *platform = gk20a_get_platform(dev);
232 struct gk20a_scale_profile *profile = platform->g->scale_profile;
233
234 if (tegra_bpmp_running()) {
235 int i;
236 ret = tegra_unpowergate_partition(TEGRA_POWERGATE_GPU);
237 for (i = 0; i < platform->num_clks; i++) {
238 if (platform->clk[i])
239 clk_prepare_enable(platform->clk[i]);
240 }
241 }
242
243 /* to start with set emc frequency floor to max rate*/
244 if (profile)
245 tegra_bwmgr_set_emc(
246 (struct tegra_bwmgr_client *)profile->private_data,
247 tegra_bwmgr_get_max_emc_rate(),
248 TEGRA_BWMGR_SET_EMC_FLOOR);
249 return ret;
250}
251
252static int gp10b_tegra_suspend(struct device *dev)
253{
254 return 0;
255}
256
257static int gp10b_tegra_reset_assert(struct device *dev)
258{
259 struct gk20a_platform *platform = gk20a_get_platform(dev);
260 int ret = 0;
261
262 if (!platform->reset_control)
263 return -EINVAL;
264
265 ret = reset_control_assert(platform->reset_control);
266
267 return ret;
268}
269
270static int gp10b_tegra_reset_deassert(struct device *dev)
271{
272 struct gk20a_platform *platform = gk20a_get_platform(dev);
273 int ret = 0;
274
275 if (!platform->reset_control)
276 return -EINVAL;
277
278 ret = reset_control_deassert(platform->reset_control);
279
280 return ret;
281}
282
283static void gp10b_tegra_prescale(struct device *dev)
284{
285 struct gk20a *g = get_gk20a(dev);
286 u32 avg = 0;
287
288 gk20a_dbg_fn("");
289
290 gk20a_pmu_load_norm(g, &avg);
291
292 gk20a_dbg_fn("done");
293}
294
295static void gp10b_tegra_postscale(struct device *pdev,
296 unsigned long freq)
297{
298 struct gk20a_platform *platform = gk20a_get_platform(pdev);
299 struct gk20a_scale_profile *profile = platform->g->scale_profile;
300 struct gk20a *g = get_gk20a(pdev);
301 unsigned long emc_rate;
302
303 gk20a_dbg_fn("");
304 if (profile && !gp10b_tegra_is_railgated(pdev)) {
305 emc_rate = (freq * EMC_BW_RATIO * g->emc3d_ratio) / 1000;
306
307 if (emc_rate > tegra_bwmgr_get_max_emc_rate())
308 emc_rate = tegra_bwmgr_get_max_emc_rate();
309
310 tegra_bwmgr_set_emc(
311 (struct tegra_bwmgr_client *)profile->private_data,
312 emc_rate, TEGRA_BWMGR_SET_EMC_FLOOR);
313 }
314 gk20a_dbg_fn("done");
315}
316
317static unsigned long gp10b_get_clk_rate(struct device *dev)
318{
319 struct gk20a_platform *platform = gk20a_get_platform(dev);
320
321 return clk_get_rate(platform->clk[0]);
322
323}
324
325static long gp10b_round_clk_rate(struct device *dev, unsigned long rate)
326{
327 struct gk20a_platform *platform = gk20a_get_platform(dev);
328
329 return clk_round_rate(platform->clk[0], rate);
330}
331
332static int gp10b_set_clk_rate(struct device *dev, unsigned long rate)
333{
334 struct gk20a_platform *platform = gk20a_get_platform(dev);
335
336 return clk_set_rate(platform->clk[0], rate);
337}
338
339static int gp10b_clk_get_freqs(struct device *dev,
340 unsigned long **freqs, int *num_freqs)
341{
342 struct gk20a_platform *platform = gk20a_get_platform(dev);
343 unsigned long min_rate, max_rate, freq_step, rate;
344 int i;
345
346 min_rate = clk_round_rate(platform->clk[0], 0);
347 max_rate = clk_round_rate(platform->clk[0], (UINT_MAX - 1));
348 freq_step = (max_rate - min_rate)/(GP10B_MAX_SUPPORTED_FREQS - 1);
349 gk20a_dbg_info("min rate: %ld max rate: %ld freq step %ld\n",
350 min_rate, max_rate, freq_step);
351
352 for (i = 0; i < GP10B_MAX_SUPPORTED_FREQS; i++) {
353 rate = min_rate + i * freq_step;
354 gp10b_freq_table[i] = clk_round_rate(platform->clk[0], rate);
355 }
356 /* Fill freq table */
357 *freqs = gp10b_freq_table;
358 *num_freqs = GP10B_MAX_SUPPORTED_FREQS;
359 return 0;
360}
361
362struct gk20a_platform t18x_gpu_tegra_platform = {
363 .has_syncpoints = true,
364
365 /* power management configuration */
366 .railgate_delay = 500,
367
368 /* power management configuration */
369 .can_railgate = true,
370 .enable_elpg = true,
371 .can_elpg = true,
372 .enable_blcg = true,
373 .enable_slcg = true,
374 .enable_elcg = true,
375 .enable_aelpg = true,
376
377 /* ptimer src frequency in hz*/
378 .ptimer_src_freq = 31250000,
379
380 .ch_wdt_timeout_ms = 5000,
381
382 .probe = gp10b_tegra_probe,
383 .late_probe = gp10b_tegra_late_probe,
384 .remove = gp10b_tegra_remove,
385
386 /* power management callbacks */
387 .suspend = gp10b_tegra_suspend,
388 .railgate = gp10b_tegra_railgate,
389 .unrailgate = gp10b_tegra_unrailgate,
390 .is_railgated = gp10b_tegra_is_railgated,
391
392 .busy = gk20a_tegra_busy,
393 .idle = gk20a_tegra_idle,
394
395 .dump_platform_dependencies = gk20a_tegra_debug_dump,
396
397 .default_big_page_size = SZ_64K,
398
399 .has_cde = true,
400
401 .has_ce = true,
402
403 .clk_get_rate = gp10b_get_clk_rate,
404 .clk_round_rate = gp10b_round_clk_rate,
405 .clk_set_rate = gp10b_set_clk_rate,
406 .get_clk_freqs = gp10b_clk_get_freqs,
407
408 /* frequency scaling configuration */
409 .prescale = gp10b_tegra_prescale,
410 .postscale = gp10b_tegra_postscale,
411 .devfreq_governor = "nvhost_podgov",
412
413 .qos_notify = gk20a_scale_qos_notify,
414
415 .secure_alloc = gk20a_tegra_secure_alloc,
416 .secure_page_alloc = gk20a_tegra_secure_page_alloc,
417
418 .reset_assert = gp10b_tegra_reset_assert,
419 .reset_deassert = gp10b_tegra_reset_deassert,
420
421 .force_reset_in_do_idle = false,
422
423 .soc_name = "tegra18x",
424
425 .vidmem_is_vidmem = false,
426};
427
428
429#define ECC_STAT_NAME_MAX_SIZE 100
430
431
432static DEFINE_HASHTABLE(ecc_hash_table, 5);
433
434static struct device_attribute *dev_attr_sm_lrf_ecc_single_err_count_array;
435static struct device_attribute *dev_attr_sm_lrf_ecc_double_err_count_array;
436
437static struct device_attribute *dev_attr_sm_shm_ecc_sec_count_array;
438static struct device_attribute *dev_attr_sm_shm_ecc_sed_count_array;
439static struct device_attribute *dev_attr_sm_shm_ecc_ded_count_array;
440
441static struct device_attribute *dev_attr_tex_ecc_total_sec_pipe0_count_array;
442static struct device_attribute *dev_attr_tex_ecc_total_ded_pipe0_count_array;
443static struct device_attribute *dev_attr_tex_ecc_unique_sec_pipe0_count_array;
444static struct device_attribute *dev_attr_tex_ecc_unique_ded_pipe0_count_array;
445static struct device_attribute *dev_attr_tex_ecc_total_sec_pipe1_count_array;
446static struct device_attribute *dev_attr_tex_ecc_total_ded_pipe1_count_array;
447static struct device_attribute *dev_attr_tex_ecc_unique_sec_pipe1_count_array;
448static struct device_attribute *dev_attr_tex_ecc_unique_ded_pipe1_count_array;
449
450static struct device_attribute *dev_attr_l2_ecc_sec_count_array;
451static struct device_attribute *dev_attr_l2_ecc_ded_count_array;
452
453
454static u32 gen_ecc_hash_key(char *str)
455{
456 int i = 0;
457 u32 hash_key = 0;
458
459 while (str[i]) {
460 hash_key += (u32)(str[i]);
461 i++;
462 };
463
464 return hash_key;
465}
466
467static ssize_t ecc_stat_show(struct device *dev,
468 struct device_attribute *attr,
469 char *buf)
470{
471 const char *ecc_stat_full_name = attr->attr.name;
472 const char *ecc_stat_base_name;
473 unsigned int hw_unit;
474 struct ecc_stat *ecc_stat;
475 u32 hash_key;
476
477 if (sscanf(ecc_stat_full_name, "ltc%u", &hw_unit) == 1) {
478 ecc_stat_base_name = &(ecc_stat_full_name[strlen("ltc0_")]);
479 } else if (sscanf(ecc_stat_full_name, "gpc0_tpc%u", &hw_unit) == 1) {
480 ecc_stat_base_name = &(ecc_stat_full_name[strlen("gpc0_tpc0_")]);
481 } else {
482 return snprintf(buf,
483 PAGE_SIZE,
484 "Error: Invalid ECC stat name!\n");
485 }
486
487 hash_key = gen_ecc_hash_key((char *)ecc_stat_base_name);
488 hash_for_each_possible(ecc_hash_table,
489 ecc_stat,
490 hash_node,
491 hash_key) {
492 if (!strcmp(ecc_stat_full_name, ecc_stat->names[hw_unit]))
493 return snprintf(buf, PAGE_SIZE, "%u\n", ecc_stat->counters[hw_unit]);
494 }
495
496 return snprintf(buf, PAGE_SIZE, "Error: No ECC stat found!\n");
497}
498
499static int ecc_stat_create(struct device *dev,
500 int is_l2,
501 char *ecc_stat_name,
502 struct ecc_stat *ecc_stat,
503 struct device_attribute *dev_attr_array)
504{
505 int error = 0;
506 struct gk20a *g = get_gk20a(dev);
507 int num_hw_units = 0;
508 int hw_unit = 0;
509 u32 hash_key = 0;
510
511 if (is_l2)
512 num_hw_units = g->ltc_count;
513 else
514 num_hw_units = g->gr.tpc_count;
515
516 /* Allocate arrays */
517 dev_attr_array = kzalloc(sizeof(struct device_attribute) * num_hw_units, GFP_KERNEL);
518 ecc_stat->counters = kzalloc(sizeof(u32) * num_hw_units, GFP_KERNEL);
519 ecc_stat->names = kzalloc(sizeof(char *) * num_hw_units, GFP_KERNEL);
520 for (hw_unit = 0; hw_unit < num_hw_units; hw_unit++) {
521 ecc_stat->names[hw_unit] = kzalloc(sizeof(char) * ECC_STAT_NAME_MAX_SIZE, GFP_KERNEL);
522 }
523
524 for (hw_unit = 0; hw_unit < num_hw_units; hw_unit++) {
525 /* Fill in struct device_attribute members */
526 if (is_l2)
527 snprintf(ecc_stat->names[hw_unit],
528 ECC_STAT_NAME_MAX_SIZE,
529 "ltc%d_%s",
530 hw_unit,
531 ecc_stat_name);
532 else
533 snprintf(ecc_stat->names[hw_unit],
534 ECC_STAT_NAME_MAX_SIZE,
535 "gpc0_tpc%d_%s",
536 hw_unit,
537 ecc_stat_name);
538
539 sysfs_attr_init(&dev_attr_array[hw_unit].attr);
540 dev_attr_array[hw_unit].attr.name = ecc_stat->names[hw_unit];
541 dev_attr_array[hw_unit].attr.mode = VERIFY_OCTAL_PERMISSIONS(S_IRUGO);
542 dev_attr_array[hw_unit].show = ecc_stat_show;
543 dev_attr_array[hw_unit].store = NULL;
544
545 /* Create sysfs file */
546 error |= device_create_file(dev, &dev_attr_array[hw_unit]);
547 }
548
549 /* Add hash table entry */
550 hash_key = gen_ecc_hash_key(ecc_stat_name);
551 hash_add(ecc_hash_table,
552 &ecc_stat->hash_node,
553 hash_key);
554
555 return error;
556}
557
558static void ecc_stat_remove(struct device *dev,
559 int is_l2,
560 struct ecc_stat *ecc_stat,
561 struct device_attribute *dev_attr_array)
562{
563 struct gk20a *g = get_gk20a(dev);
564 int num_hw_units = 0;
565 int hw_unit = 0;
566
567 if (is_l2)
568 num_hw_units = g->ltc_count;
569 else
570 num_hw_units = g->gr.tpc_count;
571
572 /* Remove sysfs files */
573 for (hw_unit = 0; hw_unit < num_hw_units; hw_unit++) {
574 device_remove_file(dev, &dev_attr_array[hw_unit]);
575 }
576
577 /* Remove hash table entry */
578 hash_del(&ecc_stat->hash_node);
579
580 /* Free arrays */
581 kfree(ecc_stat->counters);
582 for (hw_unit = 0; hw_unit < num_hw_units; hw_unit++) {
583 kfree(ecc_stat->names[hw_unit]);
584 }
585 kfree(ecc_stat->names);
586 kfree(dev_attr_array);
587}
588
589void gr_gp10b_create_sysfs(struct device *dev)
590{
591 int error = 0;
592 struct gk20a *g = get_gk20a(dev);
593
594 /* This stat creation function is called on GR init. GR can get
595 initialized multiple times but we only need to create the ECC
596 stats once. Therefore, add the following check to avoid
597 creating duplicate stat sysfs nodes. */
598 if (g->gr.t18x.ecc_stats.sm_lrf_single_err_count.counters != NULL)
599 return;
600
601 error |= ecc_stat_create(dev,
602 0,
603 "sm_lrf_ecc_single_err_count",
604 &g->gr.t18x.ecc_stats.sm_lrf_single_err_count,
605 dev_attr_sm_lrf_ecc_single_err_count_array);
606 error |= ecc_stat_create(dev,
607 0,
608 "sm_lrf_ecc_double_err_count",
609 &g->gr.t18x.ecc_stats.sm_lrf_double_err_count,
610 dev_attr_sm_lrf_ecc_double_err_count_array);
611
612 error |= ecc_stat_create(dev,
613 0,
614 "sm_shm_ecc_sec_count",
615 &g->gr.t18x.ecc_stats.sm_shm_sec_count,
616 dev_attr_sm_shm_ecc_sec_count_array);
617 error |= ecc_stat_create(dev,
618 0,
619 "sm_shm_ecc_sed_count",
620 &g->gr.t18x.ecc_stats.sm_shm_sed_count,
621 dev_attr_sm_shm_ecc_sed_count_array);
622 error |= ecc_stat_create(dev,
623 0,
624 "sm_shm_ecc_ded_count",
625 &g->gr.t18x.ecc_stats.sm_shm_ded_count,
626 dev_attr_sm_shm_ecc_ded_count_array);
627
628 error |= ecc_stat_create(dev,
629 0,
630 "tex_ecc_total_sec_pipe0_count",
631 &g->gr.t18x.ecc_stats.tex_total_sec_pipe0_count,
632 dev_attr_tex_ecc_total_sec_pipe0_count_array);
633 error |= ecc_stat_create(dev,
634 0,
635 "tex_ecc_total_ded_pipe0_count",
636 &g->gr.t18x.ecc_stats.tex_total_ded_pipe0_count,
637 dev_attr_tex_ecc_total_ded_pipe0_count_array);
638 error |= ecc_stat_create(dev,
639 0,
640 "tex_ecc_unique_sec_pipe0_count",
641 &g->gr.t18x.ecc_stats.tex_unique_sec_pipe0_count,
642 dev_attr_tex_ecc_unique_sec_pipe0_count_array);
643 error |= ecc_stat_create(dev,
644 0,
645 "tex_ecc_unique_ded_pipe0_count",
646 &g->gr.t18x.ecc_stats.tex_unique_ded_pipe0_count,
647 dev_attr_tex_ecc_unique_ded_pipe0_count_array);
648 error |= ecc_stat_create(dev,
649 0,
650 "tex_ecc_total_sec_pipe1_count",
651 &g->gr.t18x.ecc_stats.tex_total_sec_pipe1_count,
652 dev_attr_tex_ecc_total_sec_pipe1_count_array);
653 error |= ecc_stat_create(dev,
654 0,
655 "tex_ecc_total_ded_pipe1_count",
656 &g->gr.t18x.ecc_stats.tex_total_ded_pipe1_count,
657 dev_attr_tex_ecc_total_ded_pipe1_count_array);
658 error |= ecc_stat_create(dev,
659 0,
660 "tex_ecc_unique_sec_pipe1_count",
661 &g->gr.t18x.ecc_stats.tex_unique_sec_pipe1_count,
662 dev_attr_tex_ecc_unique_sec_pipe1_count_array);
663 error |= ecc_stat_create(dev,
664 0,
665 "tex_ecc_unique_ded_pipe1_count",
666 &g->gr.t18x.ecc_stats.tex_unique_ded_pipe1_count,
667 dev_attr_tex_ecc_unique_ded_pipe1_count_array);
668
669 error |= ecc_stat_create(dev,
670 1,
671 "lts0_ecc_sec_count",
672 &g->gr.t18x.ecc_stats.l2_sec_count,
673 dev_attr_l2_ecc_sec_count_array);
674 error |= ecc_stat_create(dev,
675 1,
676 "lts0_ecc_ded_count",
677 &g->gr.t18x.ecc_stats.l2_ded_count,
678 dev_attr_l2_ecc_ded_count_array);
679
680 if (error)
681 dev_err(dev, "Failed to create sysfs attributes!\n");
682}
683
684static void gr_gp10b_remove_sysfs(struct device *dev)
685{
686 struct gk20a *g = get_gk20a(dev);
687
688 ecc_stat_remove(dev,
689 0,
690 &g->gr.t18x.ecc_stats.sm_lrf_single_err_count,
691 dev_attr_sm_lrf_ecc_single_err_count_array);
692 ecc_stat_remove(dev,
693 0,
694 &g->gr.t18x.ecc_stats.sm_lrf_double_err_count,
695 dev_attr_sm_lrf_ecc_double_err_count_array);
696
697 ecc_stat_remove(dev,
698 0,
699 &g->gr.t18x.ecc_stats.sm_shm_sec_count,
700 dev_attr_sm_shm_ecc_sec_count_array);
701 ecc_stat_remove(dev,
702 0,
703 &g->gr.t18x.ecc_stats.sm_shm_sed_count,
704 dev_attr_sm_shm_ecc_sed_count_array);
705 ecc_stat_remove(dev,
706 0,
707 &g->gr.t18x.ecc_stats.sm_shm_ded_count,
708 dev_attr_sm_shm_ecc_ded_count_array);
709
710 ecc_stat_remove(dev,
711 0,
712 &g->gr.t18x.ecc_stats.tex_total_sec_pipe0_count,
713 dev_attr_tex_ecc_total_sec_pipe0_count_array);
714 ecc_stat_remove(dev,
715 0,
716 &g->gr.t18x.ecc_stats.tex_total_ded_pipe0_count,
717 dev_attr_tex_ecc_total_ded_pipe0_count_array);
718 ecc_stat_remove(dev,
719 0,
720 &g->gr.t18x.ecc_stats.tex_unique_sec_pipe0_count,
721 dev_attr_tex_ecc_unique_sec_pipe0_count_array);
722 ecc_stat_remove(dev,
723 0,
724 &g->gr.t18x.ecc_stats.tex_unique_ded_pipe0_count,
725 dev_attr_tex_ecc_unique_ded_pipe0_count_array);
726 ecc_stat_remove(dev,
727 0,
728 &g->gr.t18x.ecc_stats.tex_total_sec_pipe1_count,
729 dev_attr_tex_ecc_total_sec_pipe1_count_array);
730 ecc_stat_remove(dev,
731 0,
732 &g->gr.t18x.ecc_stats.tex_total_ded_pipe1_count,
733 dev_attr_tex_ecc_total_ded_pipe1_count_array);
734 ecc_stat_remove(dev,
735 0,
736 &g->gr.t18x.ecc_stats.tex_unique_sec_pipe1_count,
737 dev_attr_tex_ecc_unique_sec_pipe1_count_array);
738 ecc_stat_remove(dev,
739 0,
740 &g->gr.t18x.ecc_stats.tex_unique_ded_pipe1_count,
741 dev_attr_tex_ecc_unique_ded_pipe1_count_array);
742
743 ecc_stat_remove(dev,
744 1,
745 &g->gr.t18x.ecc_stats.l2_sec_count,
746 dev_attr_l2_ecc_sec_count_array);
747 ecc_stat_remove(dev,
748 1,
749 &g->gr.t18x.ecc_stats.l2_ded_count,
750 dev_attr_l2_ecc_ded_count_array);
751}
diff --git a/drivers/gpu/nvgpu/gp10b/pmu_gp10b.c b/drivers/gpu/nvgpu/gp10b/pmu_gp10b.c
new file mode 100644
index 00000000..12337934
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/pmu_gp10b.c
@@ -0,0 +1,493 @@
1/*
2 * GP10B PMU
3 *
4 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/delay.h> /* for udelay */
17#include <linux/tegra-fuse.h>
18#include "gk20a/gk20a.h"
19#include "gk20a/pmu_gk20a.h"
20#include "gm20b/acr_gm20b.h"
21#include "gm20b/pmu_gm20b.h"
22
23#include "pmu_gp10b.h"
24#include "hw_pwr_gp10b.h"
25#include "hw_fuse_gp10b.h"
26#include "gp10b_sysfs.h"
27
28#define gp10b_dbg_pmu(fmt, arg...) \
29 gk20a_dbg(gpu_dbg_pmu, fmt, ##arg)
30/*!
31 * Structure/object which single register write need to be done during PG init
32 * sequence to set PROD values.
33 */
34struct pg_init_sequence_list {
35 u32 regaddr;
36 u32 writeval;
37};
38
39/* PROD settings for ELPG sequencing registers*/
40static struct pg_init_sequence_list _pginitseq_gp10b[] = {
41 {0x0010ab10, 0x0000868B} ,
42 {0x0010e118, 0x8590848F} ,
43 {0x0010e000, 0} ,
44 {0x0010e06c, 0x000000A3} ,
45 {0x0010e06c, 0x000000A0} ,
46 {0x0010e06c, 0x00000095} ,
47 {0x0010e06c, 0x000000A6} ,
48 {0x0010e06c, 0x0000008C} ,
49 {0x0010e06c, 0x00000080} ,
50 {0x0010e06c, 0x00000081} ,
51 {0x0010e06c, 0x00000087} ,
52 {0x0010e06c, 0x00000088} ,
53 {0x0010e06c, 0x0000008D} ,
54 {0x0010e06c, 0x00000082} ,
55 {0x0010e06c, 0x00000083} ,
56 {0x0010e06c, 0x00000089} ,
57 {0x0010e06c, 0x0000008A} ,
58 {0x0010e06c, 0x000000A2} ,
59 {0x0010e06c, 0x00000097} ,
60 {0x0010e06c, 0x00000092} ,
61 {0x0010e06c, 0x00000099} ,
62 {0x0010e06c, 0x0000009B} ,
63 {0x0010e06c, 0x0000009D} ,
64 {0x0010e06c, 0x0000009F} ,
65 {0x0010e06c, 0x000000A1} ,
66 {0x0010e06c, 0x00000096} ,
67 {0x0010e06c, 0x00000091} ,
68 {0x0010e06c, 0x00000098} ,
69 {0x0010e06c, 0x0000009A} ,
70 {0x0010e06c, 0x0000009C} ,
71 {0x0010e06c, 0x0000009E} ,
72 {0x0010ab14, 0x00000000} ,
73 {0x0010e024, 0x00000000} ,
74 {0x0010e028, 0x00000000} ,
75 {0x0010e11c, 0x00000000} ,
76 {0x0010ab1c, 0x140B0BFF} ,
77 {0x0010e020, 0x0E2626FF} ,
78 {0x0010e124, 0x251010FF} ,
79 {0x0010ab20, 0x89abcdef} ,
80 {0x0010ab24, 0x00000000} ,
81 {0x0010e02c, 0x89abcdef} ,
82 {0x0010e030, 0x00000000} ,
83 {0x0010e128, 0x89abcdef} ,
84 {0x0010e12c, 0x00000000} ,
85 {0x0010ab28, 0x7FFFFFFF} ,
86 {0x0010ab2c, 0x70000000} ,
87 {0x0010e034, 0x7FFFFFFF} ,
88 {0x0010e038, 0x70000000} ,
89 {0x0010e130, 0x7FFFFFFF} ,
90 {0x0010e134, 0x70000000} ,
91 {0x0010ab30, 0x00000000} ,
92 {0x0010ab34, 0x00000001} ,
93 {0x00020004, 0x00000000} ,
94 {0x0010e138, 0x00000000} ,
95 {0x0010e040, 0x00000000} ,
96 {0x0010e168, 0x00000000} ,
97 {0x0010e114, 0x0000A5A4} ,
98 {0x0010e110, 0x00000000} ,
99 {0x0010e10c, 0x8590848F} ,
100 {0x0010e05c, 0x00000000} ,
101 {0x0010e044, 0x00000000} ,
102 {0x0010a644, 0x0000868B} ,
103 {0x0010a648, 0x00000000} ,
104 {0x0010a64c, 0x00829493} ,
105 {0x0010a650, 0x00000000} ,
106 {0x0010e000, 0} ,
107 {0x0010e068, 0x000000A3} ,
108 {0x0010e068, 0x000000A0} ,
109 {0x0010e068, 0x00000095} ,
110 {0x0010e068, 0x000000A6} ,
111 {0x0010e068, 0x0000008C} ,
112 {0x0010e068, 0x00000080} ,
113 {0x0010e068, 0x00000081} ,
114 {0x0010e068, 0x00000087} ,
115 {0x0010e068, 0x00000088} ,
116 {0x0010e068, 0x0000008D} ,
117 {0x0010e068, 0x00000082} ,
118 {0x0010e068, 0x00000083} ,
119 {0x0010e068, 0x00000089} ,
120 {0x0010e068, 0x0000008A} ,
121 {0x0010e068, 0x000000A2} ,
122 {0x0010e068, 0x00000097} ,
123 {0x0010e068, 0x00000092} ,
124 {0x0010e068, 0x00000099} ,
125 {0x0010e068, 0x0000009B} ,
126 {0x0010e068, 0x0000009D} ,
127 {0x0010e068, 0x0000009F} ,
128 {0x0010e068, 0x000000A1} ,
129 {0x0010e068, 0x00000096} ,
130 {0x0010e068, 0x00000091} ,
131 {0x0010e068, 0x00000098} ,
132 {0x0010e068, 0x0000009A} ,
133 {0x0010e068, 0x0000009C} ,
134 {0x0010e068, 0x0000009E} ,
135 {0x0010e000, 0} ,
136 {0x0010e004, 0x0000008E},
137};
138
139static void gp10b_pmu_load_multiple_falcons(struct gk20a *g, u32 falconidmask,
140 u32 flags)
141{
142 struct pmu_gk20a *pmu = &g->pmu;
143 struct pmu_cmd cmd;
144 u32 seq;
145
146 gk20a_dbg_fn("");
147
148 gp10b_dbg_pmu("wprinit status = %x\n", g->ops.pmu.lspmuwprinitdone);
149 if (g->ops.pmu.lspmuwprinitdone) {
150 /* send message to load FECS falcon */
151 memset(&cmd, 0, sizeof(struct pmu_cmd));
152 cmd.hdr.unit_id = PMU_UNIT_ACR;
153 cmd.hdr.size = PMU_CMD_HDR_SIZE +
154 sizeof(struct pmu_acr_cmd_bootstrap_multiple_falcons);
155 cmd.cmd.acr.boot_falcons.cmd_type =
156 PMU_ACR_CMD_ID_BOOTSTRAP_MULTIPLE_FALCONS;
157 cmd.cmd.acr.boot_falcons.flags = flags;
158 cmd.cmd.acr.boot_falcons.falconidmask =
159 falconidmask;
160 cmd.cmd.acr.boot_falcons.usevamask = 0;
161 cmd.cmd.acr.boot_falcons.wprvirtualbase.lo =
162 u64_lo32(g->pmu.wpr_buf.gpu_va);
163 cmd.cmd.acr.boot_falcons.wprvirtualbase.hi =
164 u64_hi32(g->pmu.wpr_buf.gpu_va);
165 gp10b_dbg_pmu("PMU_ACR_CMD_ID_BOOTSTRAP_MULTIPLE_FALCONS:%x\n",
166 falconidmask);
167 gk20a_pmu_cmd_post(g, &cmd, NULL, NULL, PMU_COMMAND_QUEUE_HPQ,
168 pmu_handle_fecs_boot_acr_msg, pmu, &seq, ~0);
169 }
170
171 gk20a_dbg_fn("done");
172 return;
173}
174
175int gp10b_load_falcon_ucode(struct gk20a *g, u32 falconidmask)
176{
177 u32 flags = PMU_ACR_CMD_BOOTSTRAP_FALCON_FLAGS_RESET_YES;
178
179 /* GM20B PMU supports loading FECS and GPCCS only */
180 if (falconidmask == 0)
181 return -EINVAL;
182 if (falconidmask & ~((1 << LSF_FALCON_ID_FECS) |
183 (1 << LSF_FALCON_ID_GPCCS)))
184 return -EINVAL;
185 g->ops.pmu.lsfloadedfalconid = 0;
186 /* check whether pmu is ready to bootstrap lsf if not wait for it */
187 if (!g->ops.pmu.lspmuwprinitdone) {
188 pmu_wait_message_cond(&g->pmu,
189 gk20a_get_gr_idle_timeout(g),
190 &g->ops.pmu.lspmuwprinitdone, 1);
191 /* check again if it still not ready indicate an error */
192 if (!g->ops.pmu.lspmuwprinitdone) {
193 gk20a_err(dev_from_gk20a(g),
194 "PMU not ready to load LSF");
195 return -ETIMEDOUT;
196 }
197 }
198 /* load falcon(s) */
199 gp10b_pmu_load_multiple_falcons(g, falconidmask, flags);
200 pmu_wait_message_cond(&g->pmu,
201 gk20a_get_gr_idle_timeout(g),
202 &g->ops.pmu.lsfloadedfalconid, falconidmask);
203 if (g->ops.pmu.lsfloadedfalconid != falconidmask)
204 return -ETIMEDOUT;
205 return 0;
206}
207
208static void pmu_handle_gr_param_msg(struct gk20a *g, struct pmu_msg *msg,
209 void *param, u32 handle, u32 status)
210{
211 gk20a_dbg_fn("");
212
213 if (status != 0) {
214 gk20a_err(dev_from_gk20a(g), "GR PARAM cmd aborted");
215 /* TBD: disable ELPG */
216 return;
217 }
218
219 gp10b_dbg_pmu("GR PARAM is acknowledged from PMU %x \n",
220 msg->msg.pg.msg_type);
221
222 return;
223}
224
225int gp10b_pg_gr_init(struct gk20a *g, u32 pg_engine_id)
226{
227 struct pmu_gk20a *pmu = &g->pmu;
228 struct pmu_cmd cmd;
229 u32 seq;
230
231 if (pg_engine_id == PMU_PG_ELPG_ENGINE_ID_GRAPHICS) {
232 memset(&cmd, 0, sizeof(struct pmu_cmd));
233 cmd.hdr.unit_id = PMU_UNIT_PG;
234 cmd.hdr.size = PMU_CMD_HDR_SIZE +
235 sizeof(struct pmu_pg_cmd_gr_init_param);
236 cmd.cmd.pg.gr_init_param.cmd_type =
237 PMU_PG_CMD_ID_PG_PARAM;
238 cmd.cmd.pg.gr_init_param.sub_cmd_id =
239 PMU_PG_PARAM_CMD_GR_INIT_PARAM;
240 cmd.cmd.pg.gr_init_param.featuremask =
241 PMU_PG_FEATURE_GR_POWER_GATING_ENABLED;
242
243 gp10b_dbg_pmu("cmd post PMU_PG_CMD_ID_PG_PARAM ");
244 gk20a_pmu_cmd_post(g, &cmd, NULL, NULL, PMU_COMMAND_QUEUE_HPQ,
245 pmu_handle_gr_param_msg, pmu, &seq, ~0);
246
247 } else
248 return -EINVAL;
249
250 return 0;
251}
252
253void gp10b_pmu_elpg_statistics(struct gk20a *g, u32 pg_engine_id,
254 u32 *ingating_time, u32 *ungating_time, u32 *gating_cnt)
255{
256 struct pmu_gk20a *pmu = &g->pmu;
257 struct pmu_pg_stats_v1 stats;
258
259 pmu_copy_from_dmem(pmu,
260 pmu->stat_dmem_offset[pg_engine_id],
261 (u8 *)&stats, sizeof(struct pmu_pg_stats_v1), 0);
262
263 *ingating_time = stats.total_sleep_timeus;
264 *ungating_time = stats.total_nonsleep_timeus;
265 *gating_cnt = stats.entry_count;
266}
267
268static int gp10b_pmu_setup_elpg(struct gk20a *g)
269{
270 int ret = 0;
271 u32 reg_writes;
272 u32 index;
273
274 gk20a_dbg_fn("");
275
276 if (g->elpg_enabled) {
277 reg_writes = ((sizeof(_pginitseq_gp10b) /
278 sizeof((_pginitseq_gp10b)[0])));
279 /* Initialize registers with production values*/
280 for (index = 0; index < reg_writes; index++) {
281 gk20a_writel(g, _pginitseq_gp10b[index].regaddr,
282 _pginitseq_gp10b[index].writeval);
283 }
284 }
285
286 gk20a_dbg_fn("done");
287 return ret;
288}
289
290void gp10b_write_dmatrfbase(struct gk20a *g, u32 addr)
291{
292 gk20a_writel(g, pwr_falcon_dmatrfbase_r(),
293 addr);
294 gk20a_writel(g, pwr_falcon_dmatrfbase1_r(),
295 0x0);
296}
297
298static int gp10b_init_pmu_setup_hw1(struct gk20a *g)
299{
300 struct pmu_gk20a *pmu = &g->pmu;
301 int err;
302
303 gk20a_dbg_fn("");
304
305 mutex_lock(&pmu->isr_mutex);
306 pmu_reset(pmu);
307 pmu->isr_enabled = true;
308 mutex_unlock(&pmu->isr_mutex);
309
310 /* setup apertures - virtual */
311 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_UCODE),
312 pwr_fbif_transcfg_mem_type_virtual_f());
313 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_VIRT),
314 pwr_fbif_transcfg_mem_type_virtual_f());
315
316 /* setup apertures - physical */
317 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_PHYS_VID),
318 pwr_fbif_transcfg_mem_type_physical_f() |
319 pwr_fbif_transcfg_target_local_fb_f());
320 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_PHYS_SYS_COH),
321 pwr_fbif_transcfg_mem_type_physical_f() |
322 pwr_fbif_transcfg_target_coherent_sysmem_f());
323 gk20a_writel(g, pwr_fbif_transcfg_r(GK20A_PMU_DMAIDX_PHYS_SYS_NCOH),
324 pwr_fbif_transcfg_mem_type_physical_f() |
325 pwr_fbif_transcfg_target_noncoherent_sysmem_f());
326
327 err = pmu_bootstrap(pmu);
328 if (err)
329 return err;
330
331 gk20a_dbg_fn("done");
332 return 0;
333
334}
335
336static void pmu_handle_ecc_en_dis_msg(struct gk20a *g, struct pmu_msg *msg,
337 void *param, u32 handle, u32 status)
338{
339 struct pmu_gk20a *pmu = &g->pmu;
340 struct pmu_msg_lrf_tex_ltc_dram_en_dis *ecc =
341 &msg->msg.lrf_tex_ltc_dram.en_dis;
342 gk20a_dbg_fn("");
343
344 if (status != 0) {
345 gk20a_err(dev_from_gk20a(g), "ECC en dis cmd aborted");
346 return;
347 }
348 if (msg->msg.lrf_tex_ltc_dram.msg_type !=
349 PMU_LRF_TEX_LTC_DRAM_MSG_ID_EN_DIS) {
350 gk20a_err(dev_from_gk20a(g),
351 "Invalid msg for LRF_TEX_LTC_DRAM_CMD_ID_EN_DIS cmd");
352 return;
353 } else if (ecc->pmu_status != 0) {
354 gk20a_err(dev_from_gk20a(g),
355 "LRF_TEX_LTC_DRAM_MSG_ID_EN_DIS msg status = %x",
356 ecc->pmu_status);
357 gk20a_err(dev_from_gk20a(g),
358 "LRF_TEX_LTC_DRAM_MSG_ID_EN_DIS msg en fail = %x",
359 ecc->en_fail_mask);
360 gk20a_err(dev_from_gk20a(g),
361 "LRF_TEX_LTC_DRAM_MSG_ID_EN_DIS msg dis fail = %x",
362 ecc->dis_fail_mask);
363 } else
364 pmu->override_done = 1;
365 gk20a_dbg_fn("done");
366}
367
368static int send_ecc_overide_en_dis_cmd(struct gk20a *g, u32 bitmask)
369{
370 struct pmu_gk20a *pmu = &g->pmu;
371 struct pmu_cmd cmd;
372 u32 seq;
373 int status;
374 u32 val;
375 gk20a_dbg_fn("");
376
377 tegra_fuse_readl(FUSE_OPT_ECC_EN, &val);
378 if (!val) {
379 gk20a_err(dev_from_gk20a(g), "Board not ECC capable");
380 return -1;
381 }
382 if (!(g->acr.capabilities &
383 ACR_LRF_TEX_LTC_DRAM_PRIV_MASK_ENABLE_LS_OVERRIDE)) {
384 gk20a_err(dev_from_gk20a(g), "check ACR capabilities");
385 return -1;
386 }
387 memset(&cmd, 0, sizeof(struct pmu_cmd));
388 cmd.hdr.unit_id = PMU_UNIT_FECS_MEM_OVERRIDE;
389 cmd.hdr.size = PMU_CMD_HDR_SIZE +
390 sizeof(struct pmu_cmd_lrf_tex_ltc_dram_en_dis);
391 cmd.cmd.lrf_tex_ltc_dram.en_dis.cmd_type =
392 PMU_LRF_TEX_LTC_DRAM_CMD_ID_EN_DIS;
393 cmd.cmd.lrf_tex_ltc_dram.en_dis.en_dis_mask = (u8)(bitmask & 0xff);
394
395 gp10b_dbg_pmu("cmd post PMU_ECC_CMD_ID_EN_DIS_ECC");
396 pmu->override_done = 0;
397 status = gk20a_pmu_cmd_post(g, &cmd, NULL, NULL, PMU_COMMAND_QUEUE_LPQ,
398 pmu_handle_ecc_en_dis_msg, NULL, &seq, ~0);
399 if (status)
400 gk20a_err(dev_from_gk20a(g), "ECC override failed");
401 else
402 pmu_wait_message_cond(pmu, gk20a_get_gr_idle_timeout(g),
403 &pmu->override_done, 1);
404 gk20a_dbg_fn("done");
405 return status;
406}
407
408static bool gp10b_is_lazy_bootstrap(u32 falcon_id)
409{
410 bool enable_status = false;
411
412 switch (falcon_id) {
413 case LSF_FALCON_ID_FECS:
414 enable_status = false;
415 break;
416 case LSF_FALCON_ID_GPCCS:
417 enable_status = true;
418 break;
419 default:
420 break;
421 }
422
423 return enable_status;
424}
425
426static bool gp10b_is_priv_load(u32 falcon_id)
427{
428 bool enable_status = false;
429
430 switch (falcon_id) {
431 case LSF_FALCON_ID_FECS:
432 enable_status = false;
433 break;
434 case LSF_FALCON_ID_GPCCS:
435 enable_status = true;
436 break;
437 default:
438 break;
439 }
440
441 return enable_status;
442}
443
444/*Dump Security related fuses*/
445static void pmu_dump_security_fuses_gp10b(struct gk20a *g)
446{
447 u32 val;
448
449 gk20a_err(dev_from_gk20a(g), "FUSE_OPT_SEC_DEBUG_EN_0 : 0x%x",
450 gk20a_readl(g, fuse_opt_sec_debug_en_r()));
451 gk20a_err(dev_from_gk20a(g), "FUSE_OPT_PRIV_SEC_EN_0 : 0x%x",
452 gk20a_readl(g, fuse_opt_priv_sec_en_r()));
453 tegra_fuse_readl(FUSE_GCPLEX_CONFIG_FUSE_0, &val);
454 gk20a_err(dev_from_gk20a(g), "FUSE_GCPLEX_CONFIG_FUSE_0 : 0x%x",
455 val);
456}
457
458static bool gp10b_is_pmu_supported(struct gk20a *g)
459{
460 return true;
461}
462
463void gp10b_init_pmu_ops(struct gpu_ops *gops)
464{
465 gops->pmu.is_pmu_supported = gp10b_is_pmu_supported;
466 if (gops->privsecurity) {
467 gm20b_init_secure_pmu(gops);
468 gops->pmu.init_wpr_region = gm20b_pmu_init_acr;
469 gops->pmu.load_lsfalcon_ucode = gp10b_load_falcon_ucode;
470 gops->pmu.is_lazy_bootstrap = gp10b_is_lazy_bootstrap;
471 gops->pmu.is_priv_load = gp10b_is_priv_load;
472 } else {
473 gk20a_init_pmu_ops(gops);
474 gops->pmu.load_lsfalcon_ucode = NULL;
475 gops->pmu.init_wpr_region = NULL;
476 gops->pmu.pmu_setup_hw_and_bootstrap = gp10b_init_pmu_setup_hw1;
477 }
478 gops->pmu.pmu_setup_elpg = gp10b_pmu_setup_elpg;
479 gops->pmu.lspmuwprinitdone = false;
480 gops->pmu.fecsbootstrapdone = false;
481 gops->pmu.write_dmatrfbase = gp10b_write_dmatrfbase;
482 gops->pmu.pmu_elpg_statistics = gp10b_pmu_elpg_statistics;
483 gops->pmu.pmu_pg_init_param = gp10b_pg_gr_init;
484 gops->pmu.pmu_pg_supported_engines_list = gk20a_pmu_pg_engines_list;
485 gops->pmu.pmu_pg_engines_feature_list = gk20a_pmu_pg_feature_list;
486 gops->pmu.pmu_lpwr_enable_pg = NULL;
487 gops->pmu.pmu_lpwr_disable_pg = NULL;
488 gops->pmu.pmu_pg_param_post_init = NULL;
489 gops->pmu.send_lrf_tex_ltc_dram_overide_en_dis_cmd =
490 send_ecc_overide_en_dis_cmd;
491 gops->pmu.reset = gk20a_pmu_reset;
492 gops->pmu.dump_secure_fuses = pmu_dump_security_fuses_gp10b;
493}
diff --git a/drivers/gpu/nvgpu/gp10b/pmu_gp10b.h b/drivers/gpu/nvgpu/gp10b/pmu_gp10b.h
new file mode 100644
index 00000000..c9ac9d41
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/pmu_gp10b.h
@@ -0,0 +1,26 @@
1/*
2 * GP10B PMU
3 *
4 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef __PMU_GP10B_H_
17#define __PMU_GP10B_H_
18
19void gp10b_init_pmu_ops(struct gpu_ops *gops);
20int gp10b_load_falcon_ucode(struct gk20a *g, u32 falconidmask);
21int gp10b_pg_gr_init(struct gk20a *g, u32 pg_engine_id);
22void gp10b_write_dmatrfbase(struct gk20a *g, u32 addr);
23void gp10b_pmu_elpg_statistics(struct gk20a *g, u32 pg_engine_id,
24 u32 *ingating_time, u32 *ungating_time, u32 *gating_cnt);
25
26#endif /*__PMU_GP10B_H_*/
diff --git a/drivers/gpu/nvgpu/gp10b/regops_gp10b.c b/drivers/gpu/nvgpu/gp10b/regops_gp10b.c
new file mode 100644
index 00000000..a494c9b8
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/regops_gp10b.c
@@ -0,0 +1,511 @@
1/*
2 * Tegra GK20A GPU Debugger Driver Register Ops
3 *
4 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#include <linux/slab.h>
20#include <linux/err.h>
21#include <linux/bsearch.h>
22#include <uapi/linux/nvgpu.h>
23
24#include "gk20a/gk20a.h"
25#include "gk20a/dbg_gpu_gk20a.h"
26#include "gk20a/regops_gk20a.h"
27#include "regops_gp10b.h"
28
29static const struct regop_offset_range gp10b_global_whitelist_ranges[] = {
30 { 0x000004f0, 1},
31 { 0x00001a00, 3},
32 { 0x00002800, 128},
33 { 0x00009400, 1},
34 { 0x00009410, 1},
35 { 0x00009480, 1},
36 { 0x00020200, 24},
37 { 0x00021c00, 4},
38 { 0x00021c14, 3},
39 { 0x00021c24, 1},
40 { 0x00021c2c, 69},
41 { 0x00021d44, 1},
42 { 0x00021d4c, 1},
43 { 0x00021d54, 1},
44 { 0x00021d5c, 1},
45 { 0x00021d64, 2},
46 { 0x00021d70, 16},
47 { 0x00022430, 7},
48 { 0x00022450, 1},
49 { 0x0002245c, 1},
50 { 0x00070000, 5},
51 { 0x000884e0, 1},
52 { 0x0008e00c, 1},
53 { 0x00100c18, 3},
54 { 0x00100c84, 1},
55 { 0x00104038, 1},
56 { 0x0010a0a8, 1},
57 { 0x0010a4f0, 1},
58 { 0x0010e490, 1},
59 { 0x0013cc14, 1},
60 { 0x00140028, 1},
61 { 0x00140280, 1},
62 { 0x001402a0, 1},
63 { 0x00140350, 1},
64 { 0x00140480, 1},
65 { 0x001404a0, 1},
66 { 0x00140550, 1},
67 { 0x00142028, 1},
68 { 0x00142280, 1},
69 { 0x001422a0, 1},
70 { 0x00142350, 1},
71 { 0x00142480, 1},
72 { 0x001424a0, 1},
73 { 0x00142550, 1},
74 { 0x0017e028, 1},
75 { 0x0017e280, 1},
76 { 0x0017e294, 1},
77 { 0x0017e29c, 2},
78 { 0x0017e2ac, 1},
79 { 0x0017e350, 1},
80 { 0x0017e39c, 1},
81 { 0x0017e480, 1},
82 { 0x0017e4a0, 1},
83 { 0x0017e550, 1},
84 { 0x00180040, 41},
85 { 0x001800ec, 10},
86 { 0x00180240, 41},
87 { 0x001802ec, 10},
88 { 0x00180440, 41},
89 { 0x001804ec, 10},
90 { 0x00180640, 41},
91 { 0x001806ec, 10},
92 { 0x00180840, 41},
93 { 0x001808ec, 10},
94 { 0x00180a40, 41},
95 { 0x00180aec, 10},
96 { 0x00180c40, 41},
97 { 0x00180cec, 10},
98 { 0x00180e40, 41},
99 { 0x00180eec, 10},
100 { 0x001a0040, 41},
101 { 0x001a00ec, 10},
102 { 0x001a0240, 41},
103 { 0x001a02ec, 10},
104 { 0x001a0440, 41},
105 { 0x001a04ec, 10},
106 { 0x001a0640, 41},
107 { 0x001a06ec, 10},
108 { 0x001a0840, 41},
109 { 0x001a08ec, 10},
110 { 0x001a0a40, 41},
111 { 0x001a0aec, 10},
112 { 0x001a0c40, 41},
113 { 0x001a0cec, 10},
114 { 0x001a0e40, 41},
115 { 0x001a0eec, 10},
116 { 0x001b0040, 41},
117 { 0x001b00ec, 10},
118 { 0x001b0240, 41},
119 { 0x001b02ec, 10},
120 { 0x001b0440, 41},
121 { 0x001b04ec, 10},
122 { 0x001b0640, 41},
123 { 0x001b06ec, 10},
124 { 0x001b0840, 41},
125 { 0x001b08ec, 10},
126 { 0x001b0a40, 41},
127 { 0x001b0aec, 10},
128 { 0x001b0c40, 41},
129 { 0x001b0cec, 10},
130 { 0x001b0e40, 41},
131 { 0x001b0eec, 10},
132 { 0x001b4000, 1},
133 { 0x001b4008, 1},
134 { 0x001b4010, 3},
135 { 0x001b4020, 3},
136 { 0x001b4030, 3},
137 { 0x001b4040, 3},
138 { 0x001b4050, 3},
139 { 0x001b4060, 4},
140 { 0x001b4074, 7},
141 { 0x001b4094, 3},
142 { 0x001b40a4, 1},
143 { 0x001b4100, 6},
144 { 0x001b4124, 2},
145 { 0x001b8000, 1},
146 { 0x001b8008, 1},
147 { 0x001b8010, 3},
148 { 0x001bc000, 1},
149 { 0x001bc008, 1},
150 { 0x001bc010, 3},
151 { 0x001be000, 1},
152 { 0x001be008, 1},
153 { 0x001be010, 3},
154 { 0x00400500, 1},
155 { 0x0040415c, 1},
156 { 0x00404468, 1},
157 { 0x00404498, 1},
158 { 0x00405800, 1},
159 { 0x00405840, 2},
160 { 0x00405850, 1},
161 { 0x00405908, 1},
162 { 0x00405b40, 1},
163 { 0x00405b50, 1},
164 { 0x00406024, 5},
165 { 0x00407010, 1},
166 { 0x00407808, 1},
167 { 0x0040803c, 1},
168 { 0x00408804, 1},
169 { 0x0040880c, 1},
170 { 0x00408900, 2},
171 { 0x00408910, 1},
172 { 0x00408944, 1},
173 { 0x00408984, 1},
174 { 0x004090a8, 1},
175 { 0x004098a0, 1},
176 { 0x00409b00, 1},
177 { 0x0041000c, 1},
178 { 0x00410110, 1},
179 { 0x00410184, 1},
180 { 0x0041040c, 1},
181 { 0x00410510, 1},
182 { 0x00410584, 1},
183 { 0x00418000, 1},
184 { 0x00418008, 1},
185 { 0x00418380, 2},
186 { 0x00418400, 2},
187 { 0x004184a0, 1},
188 { 0x00418604, 1},
189 { 0x00418680, 1},
190 { 0x00418704, 1},
191 { 0x00418714, 1},
192 { 0x00418800, 1},
193 { 0x0041881c, 1},
194 { 0x00418830, 1},
195 { 0x00418884, 1},
196 { 0x004188b0, 1},
197 { 0x004188c8, 3},
198 { 0x004188fc, 1},
199 { 0x00418b04, 1},
200 { 0x00418c04, 1},
201 { 0x00418c10, 8},
202 { 0x00418c88, 1},
203 { 0x00418d00, 1},
204 { 0x00418e00, 1},
205 { 0x00418e08, 1},
206 { 0x00418e34, 1},
207 { 0x00418e40, 4},
208 { 0x00418e58, 16},
209 { 0x00418f08, 1},
210 { 0x00419000, 1},
211 { 0x0041900c, 1},
212 { 0x00419018, 1},
213 { 0x00419854, 1},
214 { 0x00419864, 1},
215 { 0x00419a04, 2},
216 { 0x00419a14, 1},
217 { 0x00419ab0, 1},
218 { 0x00419ab8, 3},
219 { 0x00419c0c, 1},
220 { 0x00419c8c, 2},
221 { 0x00419d00, 1},
222 { 0x00419d08, 2},
223 { 0x00419e00, 11},
224 { 0x00419e34, 2},
225 { 0x00419e44, 11},
226 { 0x00419e74, 10},
227 { 0x00419ea4, 1},
228 { 0x00419eac, 2},
229 { 0x00419ee8, 1},
230 { 0x00419ef0, 28},
231 { 0x00419f70, 1},
232 { 0x00419f78, 2},
233 { 0x00419f98, 2},
234 { 0x00419fdc, 1},
235 { 0x0041a02c, 2},
236 { 0x0041a0a0, 1},
237 { 0x0041a0a8, 1},
238 { 0x0041a890, 2},
239 { 0x0041a8a0, 3},
240 { 0x0041a8b0, 2},
241 { 0x0041b014, 1},
242 { 0x0041b0a0, 1},
243 { 0x0041b0cc, 1},
244 { 0x0041b1dc, 1},
245 { 0x0041be0c, 3},
246 { 0x0041bea0, 1},
247 { 0x0041becc, 1},
248 { 0x0041bfdc, 1},
249 { 0x0041c054, 1},
250 { 0x0041c2b0, 1},
251 { 0x0041c2b8, 3},
252 { 0x0041c40c, 1},
253 { 0x0041c48c, 2},
254 { 0x0041c500, 1},
255 { 0x0041c508, 2},
256 { 0x0041c600, 11},
257 { 0x0041c634, 2},
258 { 0x0041c644, 11},
259 { 0x0041c674, 10},
260 { 0x0041c6a4, 1},
261 { 0x0041c6ac, 2},
262 { 0x0041c6e8, 1},
263 { 0x0041c6f0, 28},
264 { 0x0041c770, 1},
265 { 0x0041c778, 2},
266 { 0x0041c798, 2},
267 { 0x0041c7dc, 1},
268 { 0x0041c854, 1},
269 { 0x0041cab0, 1},
270 { 0x0041cab8, 3},
271 { 0x0041cc0c, 1},
272 { 0x0041cc8c, 2},
273 { 0x0041cd00, 1},
274 { 0x0041cd08, 2},
275 { 0x0041ce00, 11},
276 { 0x0041ce34, 2},
277 { 0x0041ce44, 11},
278 { 0x0041ce74, 10},
279 { 0x0041cea4, 1},
280 { 0x0041ceac, 2},
281 { 0x0041cee8, 1},
282 { 0x0041cef0, 28},
283 { 0x0041cf70, 1},
284 { 0x0041cf78, 2},
285 { 0x0041cf98, 2},
286 { 0x0041cfdc, 1},
287 { 0x00500384, 1},
288 { 0x005004a0, 1},
289 { 0x00500604, 1},
290 { 0x00500680, 1},
291 { 0x00500714, 1},
292 { 0x0050081c, 1},
293 { 0x00500884, 1},
294 { 0x005008b0, 1},
295 { 0x005008c8, 3},
296 { 0x005008fc, 1},
297 { 0x00500b04, 1},
298 { 0x00500c04, 1},
299 { 0x00500c10, 8},
300 { 0x00500c88, 1},
301 { 0x00500d00, 1},
302 { 0x00500e08, 1},
303 { 0x00500f08, 1},
304 { 0x00501000, 1},
305 { 0x0050100c, 1},
306 { 0x00501018, 1},
307 { 0x00501854, 1},
308 { 0x00501ab0, 1},
309 { 0x00501ab8, 3},
310 { 0x00501c0c, 1},
311 { 0x00501c8c, 2},
312 { 0x00501d00, 1},
313 { 0x00501d08, 2},
314 { 0x00501e00, 11},
315 { 0x00501e34, 2},
316 { 0x00501e44, 11},
317 { 0x00501e74, 10},
318 { 0x00501ea4, 1},
319 { 0x00501eac, 2},
320 { 0x00501ee8, 1},
321 { 0x00501ef0, 28},
322 { 0x00501f70, 1},
323 { 0x00501f78, 2},
324 { 0x00501f98, 2},
325 { 0x00501fdc, 1},
326 { 0x0050202c, 2},
327 { 0x005020a0, 1},
328 { 0x005020a8, 1},
329 { 0x00502890, 2},
330 { 0x005028a0, 3},
331 { 0x005028b0, 2},
332 { 0x00503014, 1},
333 { 0x005030a0, 1},
334 { 0x005030cc, 1},
335 { 0x005031dc, 1},
336 { 0x00503e14, 1},
337 { 0x00503ea0, 1},
338 { 0x00503ecc, 1},
339 { 0x00503fdc, 1},
340 { 0x00504054, 1},
341 { 0x005042b0, 1},
342 { 0x005042b8, 3},
343 { 0x0050440c, 1},
344 { 0x0050448c, 2},
345 { 0x00504500, 1},
346 { 0x00504508, 2},
347 { 0x00504600, 11},
348 { 0x00504634, 2},
349 { 0x00504644, 11},
350 { 0x00504674, 10},
351 { 0x005046a4, 1},
352 { 0x005046ac, 2},
353 { 0x005046e8, 1},
354 { 0x005046f0, 28},
355 { 0x00504770, 1},
356 { 0x00504778, 2},
357 { 0x00504798, 2},
358 { 0x005047dc, 1},
359 { 0x00504854, 1},
360 { 0x00504ab0, 1},
361 { 0x00504ab8, 3},
362 { 0x00504c0c, 1},
363 { 0x00504c8c, 2},
364 { 0x00504d00, 1},
365 { 0x00504d08, 2},
366 { 0x00504e00, 11},
367 { 0x00504e34, 2},
368 { 0x00504e44, 11},
369 { 0x00504e74, 10},
370 { 0x00504ea4, 1},
371 { 0x00504eac, 2},
372 { 0x00504ee8, 1},
373 { 0x00504ef0, 28},
374 { 0x00504f70, 1},
375 { 0x00504f78, 2},
376 { 0x00504f98, 2},
377 { 0x00504fdc, 1},
378 { 0x00900100, 1},
379 { 0x009a0100, 1},
380};
381
382static const u32 gp10b_global_whitelist_ranges_count =
383 ARRAY_SIZE(gp10b_global_whitelist_ranges);
384
385/* context */
386
387/* runcontrol */
388static const u32 gp10b_runcontrol_whitelist[] = {
389};
390static const u32 gp10b_runcontrol_whitelist_count =
391 ARRAY_SIZE(gp10b_runcontrol_whitelist);
392
393static const struct regop_offset_range gp10b_runcontrol_whitelist_ranges[] = {
394};
395static const u32 gp10b_runcontrol_whitelist_ranges_count =
396 ARRAY_SIZE(gp10b_runcontrol_whitelist_ranges);
397
398
399/* quad ctl */
400static const u32 gp10b_qctl_whitelist[] = {
401};
402static const u32 gp10b_qctl_whitelist_count =
403 ARRAY_SIZE(gp10b_qctl_whitelist);
404
405static const struct regop_offset_range gp10b_qctl_whitelist_ranges[] = {
406};
407static const u32 gp10b_qctl_whitelist_ranges_count =
408 ARRAY_SIZE(gp10b_qctl_whitelist_ranges);
409
410static const struct regop_offset_range *gp10b_get_global_whitelist_ranges(void)
411{
412 return gp10b_global_whitelist_ranges;
413}
414
415static int gp10b_get_global_whitelist_ranges_count(void)
416{
417 return gp10b_global_whitelist_ranges_count;
418}
419
420static const struct regop_offset_range *gp10b_get_context_whitelist_ranges(void)
421{
422 return gp10b_global_whitelist_ranges;
423}
424
425static int gp10b_get_context_whitelist_ranges_count(void)
426{
427 return gp10b_global_whitelist_ranges_count;
428}
429
430static const u32 *gp10b_get_runcontrol_whitelist(void)
431{
432 return gp10b_runcontrol_whitelist;
433}
434
435static int gp10b_get_runcontrol_whitelist_count(void)
436{
437 return gp10b_runcontrol_whitelist_count;
438}
439
440static const
441struct regop_offset_range *gp10b_get_runcontrol_whitelist_ranges(void)
442{
443 return gp10b_runcontrol_whitelist_ranges;
444}
445
446static int gp10b_get_runcontrol_whitelist_ranges_count(void)
447{
448 return gp10b_runcontrol_whitelist_ranges_count;
449}
450
451static const u32 *gp10b_get_qctl_whitelist(void)
452{
453 return gp10b_qctl_whitelist;
454}
455
456static int gp10b_get_qctl_whitelist_count(void)
457{
458 return gp10b_qctl_whitelist_count;
459}
460
461static const struct regop_offset_range *gp10b_get_qctl_whitelist_ranges(void)
462{
463 return gp10b_qctl_whitelist_ranges;
464}
465
466static int gp10b_get_qctl_whitelist_ranges_count(void)
467{
468 return gp10b_qctl_whitelist_ranges_count;
469}
470
471static int gp10b_apply_smpc_war(struct dbg_session_gk20a *dbg_s)
472{
473 /* Not needed on gp10b */
474 return 0;
475}
476
477void gp10b_init_regops(struct gpu_ops *gops)
478{
479 gops->regops.get_global_whitelist_ranges =
480 gp10b_get_global_whitelist_ranges;
481 gops->regops.get_global_whitelist_ranges_count =
482 gp10b_get_global_whitelist_ranges_count;
483
484 gops->regops.get_context_whitelist_ranges =
485 gp10b_get_context_whitelist_ranges;
486 gops->regops.get_context_whitelist_ranges_count =
487 gp10b_get_context_whitelist_ranges_count;
488
489 gops->regops.get_runcontrol_whitelist =
490 gp10b_get_runcontrol_whitelist;
491 gops->regops.get_runcontrol_whitelist_count =
492 gp10b_get_runcontrol_whitelist_count;
493
494 gops->regops.get_runcontrol_whitelist_ranges =
495 gp10b_get_runcontrol_whitelist_ranges;
496 gops->regops.get_runcontrol_whitelist_ranges_count =
497 gp10b_get_runcontrol_whitelist_ranges_count;
498
499 gops->regops.get_qctl_whitelist =
500 gp10b_get_qctl_whitelist;
501 gops->regops.get_qctl_whitelist_count =
502 gp10b_get_qctl_whitelist_count;
503
504 gops->regops.get_qctl_whitelist_ranges =
505 gp10b_get_qctl_whitelist_ranges;
506 gops->regops.get_qctl_whitelist_ranges_count =
507 gp10b_get_qctl_whitelist_ranges_count;
508
509 gops->regops.apply_smpc_war =
510 gp10b_apply_smpc_war;
511}
diff --git a/drivers/gpu/nvgpu/gp10b/regops_gp10b.h b/drivers/gpu/nvgpu/gp10b/regops_gp10b.h
new file mode 100644
index 00000000..8727951a
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/regops_gp10b.h
@@ -0,0 +1,24 @@
1/*
2 *
3 * Tegra GP10B GPU Debugger Driver Register Ops
4 *
5 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2, as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef __REGOPS_GP10B_H_
20#define __REGOPS_GP10B_H_
21
22void gp10b_init_regops(struct gpu_ops *gops);
23
24#endif /* __REGOPS_GP10B_H_ */
diff --git a/drivers/gpu/nvgpu/gp10b/rpfb_gp10b.c b/drivers/gpu/nvgpu/gp10b/rpfb_gp10b.c
new file mode 100644
index 00000000..f88718b6
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/rpfb_gp10b.c
@@ -0,0 +1,150 @@
1/*
2 * GP10B RPFB
3 *
4 * Copyright (c) 2015, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/pm_runtime.h>
17#include <linux/dma-mapping.h>
18#include "gk20a/gk20a.h"
19#include "rpfb_gp10b.h"
20#include "hw_fifo_gp10b.h"
21#include "hw_fb_gp10b.h"
22#include "hw_bus_gp10b.h"
23#include "hw_gmmu_gp10b.h"
24
25int gp10b_replayable_pagefault_buffer_init(struct gk20a *g)
26{
27 u32 addr_lo;
28 u32 addr_hi;
29 struct vm_gk20a *vm = &g->mm.bar2.vm;
30 int err;
31 size_t rbfb_size = NV_UVM_FAULT_BUF_SIZE *
32 fifo_replay_fault_buffer_size_hw_entries_v();
33
34 gk20a_dbg_fn("");
35
36 if (!g->mm.bar2_desc.gpu_va) {
37 err = gk20a_gmmu_alloc_map_sys(vm, rbfb_size,
38 &g->mm.bar2_desc);
39 if (err) {
40 dev_err(dev_from_gk20a(g),
41 "%s Error in replayable fault buffer\n", __func__);
42 return err;
43 }
44 }
45 addr_lo = u64_lo32(g->mm.bar2_desc.gpu_va >> 12);
46 addr_hi = u64_hi32(g->mm.bar2_desc.gpu_va);
47 gk20a_writel(g, fifo_replay_fault_buffer_hi_r(),
48 fifo_replay_fault_buffer_hi_base_f(addr_hi));
49
50 gk20a_writel(g, fifo_replay_fault_buffer_lo_r(),
51 fifo_replay_fault_buffer_lo_base_f(addr_lo) |
52 fifo_replay_fault_buffer_lo_enable_true_v());
53 gk20a_dbg_fn("done");
54 return 0;
55}
56
57void gp10b_replayable_pagefault_buffer_deinit(struct gk20a *g)
58{
59 struct vm_gk20a *vm = &g->mm.bar2.vm;
60
61 gk20a_gmmu_unmap_free(vm, &g->mm.bar2_desc);
62}
63
64u32 gp10b_replayable_pagefault_buffer_get_index(struct gk20a *g)
65{
66 u32 get_idx = 0;
67
68 gk20a_dbg_fn("");
69
70 get_idx = gk20a_readl(g, fifo_replay_fault_buffer_get_r());
71
72 if (get_idx >= fifo_replay_fault_buffer_size_hw_entries_v())
73 dev_err(dev_from_gk20a(g), "%s Error in replayable fault buffer\n",
74 __func__);
75 gk20a_dbg_fn("done");
76 return get_idx;
77}
78
79u32 gp10b_replayable_pagefault_buffer_put_index(struct gk20a *g)
80{
81 u32 put_idx = 0;
82
83 gk20a_dbg_fn("");
84 put_idx = gk20a_readl(g, fifo_replay_fault_buffer_put_r());
85
86 if (put_idx >= fifo_replay_fault_buffer_size_hw_entries_v())
87 dev_err(dev_from_gk20a(g), "%s Error in UVM\n",
88 __func__);
89 gk20a_dbg_fn("done");
90 return put_idx;
91}
92
93bool gp10b_replayable_pagefault_buffer_is_empty(struct gk20a *g)
94{
95 u32 get_idx = gk20a_readl(g, fifo_replay_fault_buffer_get_r());
96 u32 put_idx = gk20a_readl(g, fifo_replay_fault_buffer_put_r());
97
98 return (get_idx == put_idx ? true : false);
99}
100
101bool gp10b_replayable_pagefault_buffer_is_full(struct gk20a *g)
102{
103 u32 get_idx = gk20a_readl(g, fifo_replay_fault_buffer_get_r());
104 u32 put_idx = gk20a_readl(g, fifo_replay_fault_buffer_put_r());
105 u32 hw_entries = gk20a_readl(g, fifo_replay_fault_buffer_size_r());
106
107 return (get_idx == ((put_idx + 1) % hw_entries) ? true : false);
108}
109
110bool gp10b_replayable_pagefault_buffer_is_overflow(struct gk20a *g)
111{
112 u32 info = gk20a_readl(g, fifo_replay_fault_buffer_info_r());
113
114 return fifo_replay_fault_buffer_info_overflow_f(info);
115}
116
117void gp10b_replayable_pagefault_buffer_clear_overflow(struct gk20a *g)
118{
119 u32 info = gk20a_readl(g, fifo_replay_fault_buffer_info_r());
120
121 info |= fifo_replay_fault_buffer_info_overflow_clear_v();
122 gk20a_writel(g, fifo_replay_fault_buffer_info_r(), info);
123
124}
125
126void gp10b_replayable_pagefault_buffer_info(struct gk20a *g)
127{
128
129 gk20a_dbg_fn("");
130 pr_info("rpfb low: 0x%x\n",
131 (gk20a_readl(g, fifo_replay_fault_buffer_lo_r()) >> 12));
132 pr_info("rpfb hi: 0x%x\n",
133 gk20a_readl(g, fifo_replay_fault_buffer_hi_r()));
134 pr_info("rpfb enabled: 0x%x\n",
135 (gk20a_readl(g, fifo_replay_fault_buffer_lo_r()) & 0x1));
136 pr_info("rpfb size: %d\n",
137 gk20a_readl(g, fifo_replay_fault_buffer_size_r()));
138 pr_info("rpfb get index: %d\n",
139 gp10b_replayable_pagefault_buffer_get_index(g));
140 pr_info("rpfb put index: %d\n",
141 gp10b_replayable_pagefault_buffer_put_index(g));
142 pr_info("rpfb empty: %d\n",
143 gp10b_replayable_pagefault_buffer_is_empty(g));
144 pr_info("rpfb full %d\n",
145 gp10b_replayable_pagefault_buffer_is_full(g));
146 pr_info("rpfb overflow %d\n",
147 gp10b_replayable_pagefault_buffer_is_overflow(g));
148
149 gk20a_dbg_fn("done");
150}
diff --git a/drivers/gpu/nvgpu/gp10b/rpfb_gp10b.h b/drivers/gpu/nvgpu/gp10b/rpfb_gp10b.h
new file mode 100644
index 00000000..965c9573
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/rpfb_gp10b.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright (c) 2015, 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
14#ifndef RPFB_GP20B_H
15#define RPFB_GP20B_H
16struct gk20a;
17
18#define NV_UVM_FAULT_BUF_SIZE 32
19
20int gp10b_replayable_pagefault_buffer_init(struct gk20a *g);
21u32 gp10b_replayable_pagefault_buffer_get_index(struct gk20a *g);
22u32 gp10b_replayable_pagefault_buffer_put_index(struct gk20a *g);
23bool gp10b_replayable_pagefault_buffer_is_empty(struct gk20a *g);
24bool gp10b_replayable_pagefault_buffer_is_full(struct gk20a *g);
25bool gp10b_replayable_pagefault_buffer_is_overflow(struct gk20a *g);
26void gp10b_replayable_pagefault_buffer_clear_overflow(struct gk20a *g);
27void gp10b_replayable_pagefault_buffer_info(struct gk20a *g);
28void gp10b_replayable_pagefault_buffer_deinit(struct gk20a *g);
29
30#endif
diff --git a/drivers/gpu/nvgpu/gp10b/therm_gp10b.c b/drivers/gpu/nvgpu/gp10b/therm_gp10b.c
new file mode 100644
index 00000000..7f43cb56
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/therm_gp10b.c
@@ -0,0 +1,130 @@
1/*
2 * drivers/gpu/nvgpu/gm20b/therm_gk20a.c
3 *
4 * GP10B Therm
5 *
6 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 */
17
18#include "gk20a/gk20a.h"
19#include "hw_therm_gp10b.h"
20
21static int gp10b_init_therm_setup_hw(struct gk20a *g)
22{
23 u32 v;
24
25 gk20a_dbg_fn("");
26
27 /* program NV_THERM registers */
28 gk20a_writel(g, therm_use_a_r(), therm_use_a_ext_therm_0_enable_f() |
29 therm_use_a_ext_therm_1_enable_f() |
30 therm_use_a_ext_therm_2_enable_f());
31 gk20a_writel(g, therm_evt_ext_therm_0_r(),
32 therm_evt_ext_therm_0_slow_factor_f(0x2));
33 gk20a_writel(g, therm_evt_ext_therm_1_r(),
34 therm_evt_ext_therm_1_slow_factor_f(0x6));
35 gk20a_writel(g, therm_evt_ext_therm_2_r(),
36 therm_evt_ext_therm_2_slow_factor_f(0xe));
37
38 gk20a_writel(g, therm_grad_stepping_table_r(0),
39 therm_grad_stepping_table_slowdown_factor0_f(
40 therm_grad_stepping_table_slowdown_factor0_fpdiv_by1p5_f()) |
41 therm_grad_stepping_table_slowdown_factor1_f(
42 therm_grad_stepping_table_slowdown_factor0_fpdiv_by2_f()) |
43 therm_grad_stepping_table_slowdown_factor2_f(
44 therm_grad_stepping_table_slowdown_factor0_fpdiv_by4_f()) |
45 therm_grad_stepping_table_slowdown_factor3_f(
46 therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
47 therm_grad_stepping_table_slowdown_factor4_f(
48 therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()));
49
50 gk20a_writel(g, therm_grad_stepping_table_r(1),
51 therm_grad_stepping_table_slowdown_factor0_f(
52 therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
53 therm_grad_stepping_table_slowdown_factor1_f(
54 therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
55 therm_grad_stepping_table_slowdown_factor2_f(
56 therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
57 therm_grad_stepping_table_slowdown_factor3_f(
58 therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()) |
59 therm_grad_stepping_table_slowdown_factor4_f(
60 therm_grad_stepping_table_slowdown_factor0_fpdiv_by8_f()));
61
62 v = gk20a_readl(g, therm_clk_timing_r(0));
63 v |= therm_clk_timing_grad_slowdown_enabled_f();
64 gk20a_writel(g, therm_clk_timing_r(0), v);
65
66 v = gk20a_readl(g, therm_config2_r());
67 v |= therm_config2_grad_enable_f(1);
68 v |= therm_config2_slowdown_factor_extended_f(1);
69 gk20a_writel(g, therm_config2_r(), v);
70
71 gk20a_writel(g, therm_grad_stepping1_r(),
72 therm_grad_stepping1_pdiv_duration_f(32));
73
74 v = gk20a_readl(g, therm_grad_stepping0_r());
75 v |= therm_grad_stepping0_feature_enable_f();
76 gk20a_writel(g, therm_grad_stepping0_r(), v);
77
78 return 0;
79}
80
81static int gp10b_elcg_init_idle_filters(struct gk20a *g)
82{
83 u32 gate_ctrl, idle_filter;
84 u32 engine_id;
85 u32 active_engine_id = 0;
86 struct fifo_gk20a *f = &g->fifo;
87
88 gk20a_dbg_fn("");
89
90 for (engine_id = 0; engine_id < f->num_engines; engine_id++) {
91 active_engine_id = f->active_engines_list[engine_id];
92 gate_ctrl = gk20a_readl(g, therm_gate_ctrl_r(active_engine_id));
93
94 if (tegra_platform_is_linsim()) {
95 gate_ctrl = set_field(gate_ctrl,
96 therm_gate_ctrl_eng_delay_after_m(),
97 therm_gate_ctrl_eng_delay_after_f(4));
98 }
99
100 /* 2 * (1 << 9) = 1024 clks */
101 gate_ctrl = set_field(gate_ctrl,
102 therm_gate_ctrl_eng_idle_filt_exp_m(),
103 therm_gate_ctrl_eng_idle_filt_exp_f(9));
104 gate_ctrl = set_field(gate_ctrl,
105 therm_gate_ctrl_eng_idle_filt_mant_m(),
106 therm_gate_ctrl_eng_idle_filt_mant_f(2));
107 gate_ctrl = set_field(gate_ctrl,
108 therm_gate_ctrl_eng_delay_before_m(),
109 therm_gate_ctrl_eng_delay_before_f(4));
110 gk20a_writel(g, therm_gate_ctrl_r(active_engine_id), gate_ctrl);
111 }
112
113 /* default fecs_idle_filter to 0 */
114 idle_filter = gk20a_readl(g, therm_fecs_idle_filter_r());
115 idle_filter &= ~therm_fecs_idle_filter_value_m();
116 gk20a_writel(g, therm_fecs_idle_filter_r(), idle_filter);
117 /* default hubmmu_idle_filter to 0 */
118 idle_filter = gk20a_readl(g, therm_hubmmu_idle_filter_r());
119 idle_filter &= ~therm_hubmmu_idle_filter_value_m();
120 gk20a_writel(g, therm_hubmmu_idle_filter_r(), idle_filter);
121
122 gk20a_dbg_fn("done");
123 return 0;
124}
125
126void gp10b_init_therm_ops(struct gpu_ops *gops)
127{
128 gops->therm.init_therm_setup_hw = gp10b_init_therm_setup_hw;
129 gops->therm.elcg_init_idle_filters = gp10b_elcg_init_idle_filters;
130}
diff --git a/drivers/gpu/nvgpu/gp10b/therm_gp10b.h b/drivers/gpu/nvgpu/gp10b/therm_gp10b.h
new file mode 100644
index 00000000..18c102fe
--- /dev/null
+++ b/drivers/gpu/nvgpu/gp10b/therm_gp10b.h
@@ -0,0 +1,19 @@
1/*
2 * Copyright (c) 2015, 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#ifndef THERM_GP10B_H
14#define THERM_GP10B_H
15
16struct gpu_ops;
17void gp10b_init_therm_ops(struct gpu_ops *gops);
18
19#endif /* THERM_GP10B_H */
diff --git a/drivers/gpu/nvgpu/gr_t18x.h b/drivers/gpu/nvgpu/gr_t18x.h
new file mode 100644
index 00000000..95601116
--- /dev/null
+++ b/drivers/gpu/nvgpu/gr_t18x.h
@@ -0,0 +1,20 @@
1/*
2 * NVIDIA T18x GR
3 *
4 * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _NVGPU_GR_T18X_H_
16#define _NVGPU_GR_T18X_H_
17
18#include "gp10b/gr_gp10b.h"
19
20#endif
diff --git a/drivers/gpu/nvgpu/include/bios.h b/drivers/gpu/nvgpu/include/bios.h
new file mode 100644
index 00000000..097e90ec
--- /dev/null
+++ b/drivers/gpu/nvgpu/include/bios.h
@@ -0,0 +1,992 @@
1/*
2 * vbios tables support
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef NVGPU_INCLUDE_BIOS_H
17#define NVGPU_INCLUDE_BIOS_H
18
19#include "gk20a/gk20a.h"
20
21#define BIOS_GET_FIELD(value, name) ((value & name##_MASK) >> name##_SHIFT)
22
23struct fll_descriptor_header {
24 u8 version;
25 u8 size;
26} __packed;
27
28#define FLL_DESCRIPTOR_HEADER_10_SIZE_4 4
29#define FLL_DESCRIPTOR_HEADER_10_SIZE_6 6
30
31struct fll_descriptor_header_10 {
32 u8 version;
33 u8 header_size;
34 u8 entry_size;
35 u8 entry_count;
36 u16 max_min_freq_mhz;
37} __packed;
38
39#define FLL_DESCRIPTOR_ENTRY_10_SIZE 15
40
41struct fll_descriptor_entry_10 {
42 u8 fll_device_type;
43 u8 clk_domain;
44 u8 fll_device_id;
45 u16 lut_params;
46 u8 vin_idx_logic;
47 u8 vin_idx_sram;
48 u16 fll_params;
49 u8 min_freq_vfe_idx;
50 u8 freq_ctrl_idx;
51 u16 ref_freq_mhz;
52 u16 ffr_cutoff_freq_mhz;
53} __packed;
54
55#define NV_FLL_DESC_FLL_PARAMS_MDIV_MASK 0x1F
56#define NV_FLL_DESC_FLL_PARAMS_MDIV_SHIFT 0
57
58#define NV_FLL_DESC_LUT_PARAMS_VSELECT_MASK 0x3
59#define NV_FLL_DESC_LUT_PARAMS_VSELECT_SHIFT 0
60
61#define NV_FLL_DESC_LUT_PARAMS_HYSTERISIS_THRESHOLD_MASK 0x3C
62#define NV_FLL_DESC_LUT_PARAMS_HYSTERISIS_THRESHOLD_SHIFT 2
63
64struct vin_descriptor_header_10 {
65 u8 version;
66 u8 header_sizee;
67 u8 entry_size;
68 u8 entry_count;
69 u8 flags0;
70 u32 vin_cal;
71} __packed;
72
73struct vin_descriptor_entry_10 {
74 u8 vin_device_type;
75 u8 volt_domain_vbios;
76 u8 vin_device_id;
77} __packed;
78
79#define NV_VIN_DESC_FLAGS0_VIN_CAL_REVISION_MASK 0x7
80#define NV_VIN_DESC_FLAGS0_VIN_CAL_REVISION_SHIFT 0
81
82#define NV_VIN_DESC_FLAGS0_DISABLE_CONTROL_MASK 0x8
83#define NV_VIN_DESC_FLAGS0_DISABLE_CONTROL_SHIFT 3
84
85#define NV_VIN_DESC_VIN_CAL_SLOPE_FRACTION_MASK 0x1FF
86#define NV_VIN_DESC_VIN_CAL_SLOPE_FRACTION_SHIFT 0
87
88#define NV_VIN_DESC_VIN_CAL_SLOPE_INTEGER_MASK 0x3C00
89#define NV_VIN_DESC_VIN_CAL_SLOPE_INTEGER_SHIFT 10
90
91#define NV_VIN_DESC_VIN_CAL_INTERCEPT_FRACTION_MASK 0x3C000
92#define NV_VIN_DESC_VIN_CAL_INTERCEPT_FRACTION_SHIFT 14
93
94#define NV_VIN_DESC_VIN_CAL_INTERCEPT_INTEGER_MASK 0xFFC0000
95#define NV_VIN_DESC_VIN_CAL_INTERCEPT_INTEGER_SHIFT 18
96
97#define VBIOS_CLOCKS_TABLE_1X_HEADER_SIZE_07 0x07
98struct vbios_clocks_table_1x_header {
99 u8 version;
100 u8 header_size;
101 u8 entry_size;
102 u8 entry_count;
103 u8 clocks_hal;
104 u16 cntr_sampling_periodms;
105} __packed;
106
107#define VBIOS_CLOCKS_TABLE_1X_ENTRY_SIZE_09 0x09
108struct vbios_clocks_table_1x_entry {
109 u8 flags0;
110 u16 param0;
111 u32 param1;
112 u16 param2;
113} __packed;
114
115#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_FLAGS0_USAGE_MASK 0x1F
116#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_FLAGS0_USAGE_SHIFT 0
117#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_FLAGS0_USAGE_FIXED 0x00
118#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_FLAGS0_USAGE_MASTER 0x01
119#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_FLAGS0_USAGE_SLAVE 0x02
120
121#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM0_PROG_CLK_PROG_IDX_FIRST_MASK 0xFF
122#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM0_PROG_CLK_PROG_IDX_FIRST_SHIFT 0
123#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM0_PROG_CLK_PROG_IDX_LAST_MASK 0xFF00
124#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM0_PROG_CLK_PROG_IDX_LAST_SHIFT 0x08
125
126#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_FIXED_FREQUENCY_MHZ_MASK 0xFFFF
127#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_FIXED_FREQUENCY_MHZ_SHIFT 0
128#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_MASTER_FREQ_OC_DELTA_MIN_MHZ_MASK 0xFFFF
129#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_MASTER_FREQ_OC_DELTA_MIN_MHZ_SHIFT 0
130
131#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_MASTER_FREQ_OC_DELTA_MAX_MHZ_MASK 0xFFFF0000
132#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_MASTER_FREQ_OC_DELTA_MAX_MHZ_SHIFT 0
133
134#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_SLAVE_MASTER_DOMAIN_MASK 0xF
135#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM1_SLAVE_MASTER_DOMAIN_SHIFT 0
136
137#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_NOISE_UNAWARE_ORDERING_IDX_MASK 0xF
138#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_NOISE_UNAWARE_ORDERING_IDX_SHIFT 0
139
140#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_NOISE_AWARE_ORDERING_IDX_MASK 0xF0
141#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_NOISE_AWARE_ORDERING_IDX_SHIFT 4
142
143#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_FORCE_NOISE_UNAWARE_ORDERING_MASK 0x100
144#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_FORCE_NOISE_UNAWARE_ORDERING_SHIFT 8
145#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_FORCE_NOISE_UNAWARE_ORDERING_FALSE 0x00
146#define NV_VBIOS_CLOCKS_TABLE_1X_ENTRY_PARAM2_PROG_FORCE_NOISE_UNAWARE_ORDERING_TRUE 0x01
147
148#define VBIOS_CLOCK_PROGRAMMING_TABLE_1X_HEADER_SIZE_08 0x08
149struct vbios_clock_programming_table_1x_header {
150 u8 version;
151 u8 header_size;
152 u8 entry_size;
153 u8 entry_count;
154 u8 slave_entry_size;
155 u8 slave_entry_count;
156 u8 vf_entry_size;
157 u8 vf_entry_count;
158} __packed;
159
160#define VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_SIZE_05 0x05
161#define VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_SIZE_0D 0x0D
162struct vbios_clock_programming_table_1x_entry {
163 u8 flags0;
164 u16 freq_max_mhz;
165 u8 param0;
166 u8 param1;
167 u32 rsvd;
168 u32 rsvd1;
169} __packed;
170
171#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_MASK 0xF
172#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_SHIFT 0
173#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_MASTER_RATIO 0x00
174#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_MASTER_TABLE 0x01
175#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_TYPE_SLAVE 0x02
176
177#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_SOURCE_MASK 0x70
178#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_SOURCE_SHIFT 4
179#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_SOURCE_PLL 0x00
180#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_SOURCE_ONE_SOURCE 0x01
181#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_SOURCE_FLL 0x02
182
183#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_OVOC_ENABLED_MASK 0x80
184#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_OVOC_ENABLED_SHIFT 7
185#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_OVOC_ENABLED_FALSE 0x00
186#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_FLAGS0_OVOC_ENABLED_TRUE 0x01
187
188#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_PARAM0_PLL_PLL_INDEX_MASK 0xFF
189#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_PARAM0_PLL_PLL_INDEX_SHIFT 0
190
191#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_PARAM1_PLL_FREQ_STEP_SIZE_MASK 0xFF
192#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_ENTRY_PARAM1_PLL_FREQ_STEP_SIZE_SHIFT 0
193
194#define VBIOS_CLOCK_PROGRAMMING_TABLE_1X_SLAVE_ENTRY_SIZE_03 0x03
195struct vbios_clock_programming_table_1x_slave_entry {
196 u8 clk_dom_idx;
197 u16 param0;
198} __packed;
199
200#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_SLAVE_ENTRY_PARAM0_MASTER_RATIO_RATIO_MASK 0xFF
201#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_SLAVE_ENTRY_PARAM0_MASTER_RATIO_RATIO_SHIFT 0
202
203#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_SLAVE_ENTRY_PARAM0_MASTER_TABLE_FREQ_MASK 0x3FFF
204#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_SLAVE_ENTRY_PARAM0_MASTER_TABLE_FREQ_SHIFT 0
205
206#define VBIOS_CLOCK_PROGRAMMING_TABLE_1X_VF_ENTRY_SIZE_02 0x02
207struct vbios_clock_programming_table_1x_vf_entry {
208 u8 vfe_idx;
209 u8 param0;
210} __packed;
211
212#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_VF_ENTRY_PARAM0_FLL_GAIN_VFE_IDX_MASK 0xFF
213#define NV_VBIOS_CLOCK_PROGRAMMING_TABLE_1X_VF_ENTRY_PARAM0_FLL_GAIN_VFE_IDX_SHIFT 0
214
215struct vbios_vfe_3x_header_struct {
216 u8 version;
217 u8 header_size;
218 u8 vfe_var_entry_size;
219 u8 vfe_var_entry_count;
220 u8 vfe_equ_entry_size;
221 u8 vfe_equ_entry_count;
222 u8 polling_periodms;
223} __packed;
224
225#define VBIOS_VFE_3X_VAR_ENTRY_SIZE_11 0x11
226#define VBIOS_VFE_3X_VAR_ENTRY_SIZE_19 0x19
227struct vbios_vfe_3x_var_entry_struct {
228 u8 type;
229 u32 out_range_min;
230 u32 out_range_max;
231 u32 param0;
232 u32 param1;
233 u32 param2;
234 u32 param3;
235} __packed;
236
237#define VBIOS_VFE_3X_VAR_ENTRY_TYPE_DISABLED 0x00
238#define VBIOS_VFE_3X_VAR_ENTRY_TYPE_SINGLE_FREQUENCY 0x01
239#define VBIOS_VFE_3X_VAR_ENTRY_TYPE_SINGLE_VOLTAGE 0x02
240#define VBIOS_VFE_3X_VAR_ENTRY_TYPE_SINGLE_SENSED_TEMP 0x03
241#define VBIOS_VFE_3X_VAR_ENTRY_TYPE_SINGLE_SENSED_FUSE 0x04
242#define VBIOS_VFE_3X_VAR_ENTRY_TYPE_DERIVED_PRODUCT 0x05
243#define VBIOS_VFE_3X_VAR_ENTRY_TYPE_DERIVED_SUM 0x06
244
245#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSTEMP_TH_CH_IDX_MASK 0xFF
246#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSTEMP_TH_CH_IDX_SHIFT 0
247
248#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSTEMP_HYS_POS_MASK 0xFF00
249#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSTEMP_HYS_POS_SHIFT 8
250
251#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSTEMP_HYS_NEG_MASK 0xFF0000
252#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSTEMP_HYS_NEG_SHIFT 16
253
254#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_VFIELD_ID_MASK 0xFF
255#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_VFIELD_ID_SHIFT 0
256
257#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_VFIELD_ID_VER_MASK 0xFF00
258#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_VFIELD_ID_VER_SHIFT 8
259
260#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_EXPECTED_VER_MASK 0xFF0000
261#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_EXPECTED_VER_SHIFT 16
262
263#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_USE_DEFAULT_ON_VER_CHECK_FAIL_MASK 0x1000000
264#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_USE_DEFAULT_ON_VER_CHECK_FAIL_SHIFT 24
265
266#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_USE_DEFAULT_ON_VER_CHECK_FAIL_YES 0x00000001
267#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_USE_DEFAULT_ON_VER_CHECK_FAIL_NO 0x00000000
268#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_DPROD_VFE_VAR_IDX_0_MASK 0xFF
269#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_DPROD_VFE_VAR_IDX_0_SHIFT 0
270
271#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_DPROD_VFE_VAR_IDX_1_MASK 0xFF00
272#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_DPROD_VFE_VAR_IDX_1_SHIFT 8
273
274#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_DSUM_VFE_VAR_IDX_0_MASK 0xFF
275#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_DSUM_VFE_VAR_IDX_0_SHIFT 0
276
277#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_DSUM_VFE_VAR_IDX_1_MASK 0xFF00
278#define VBIOS_VFE_3X_VAR_ENTRY_PAR0_DSUM_VFE_VAR_IDX_1_SHIFT 8
279
280#define VBIOS_VFE_3X_VAR_ENTRY_PAR1_SSFUSE_DEFAULT_VAL_MASK 0xFFFFFFFF
281#define VBIOS_VFE_3X_VAR_ENTRY_PAR1_SSFUSE_DEFAULT_VAL_SHIFT 0
282
283#define VBIOS_VFE_3X_VAR_ENTRY_PAR1_SSFUSE_HW_CORRECTION_SCALE_MASK 0xFFFFFFFF
284#define VBIOS_VFE_3X_VAR_ENTRY_PAR1_SSFUSE_HW_CORRECTION_SCALE_SHIFT 0
285
286#define VBIOS_VFE_3X_VAR_ENTRY_PAR1_SSFUSE_HW_CORRECTION_OFFSET_MASK 0xFFFFFFFF
287#define VBIOS_VFE_3X_VAR_ENTRY_PAR1_SSFUSE_HW_CORRECTION_OFFSET_SHIFT 0
288
289#define VBIOS_VFE_3X_EQU_ENTRY_SIZE_17 0x17
290#define VBIOS_VFE_3X_EQU_ENTRY_SIZE_18 0x18
291
292struct vbios_vfe_3x_equ_entry_struct {
293 u8 type;
294 u8 var_idx;
295 u8 equ_idx_next;
296 u32 out_range_min;
297 u32 out_range_max;
298 u32 param0;
299 u32 param1;
300 u32 param2;
301 u8 param3;
302} __packed;
303
304
305#define VBIOS_VFE_3X_EQU_ENTRY_TYPE_DISABLED 0x00
306#define VBIOS_VFE_3X_EQU_ENTRY_TYPE_QUADRATIC 0x01
307#define VBIOS_VFE_3X_EQU_ENTRY_TYPE_MINMAX 0x02
308#define VBIOS_VFE_3X_EQU_ENTRY_TYPE_COMPARE 0x03
309#define VBIOS_VFE_3X_EQU_ENTRY_TYPE_QUADRATIC_FXP 0x04
310#define VBIOS_VFE_3X_EQU_ENTRY_TYPE_MINMAX_FXP 0x05
311
312#define VBIOS_VFE_3X_EQU_ENTRY_IDX_INVALID 0xFF
313
314#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_QUADRATIC_C0_MASK 0xFFFFFFFF
315#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_QUADRATIC_C0_SHIFT 0
316
317#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_VFE_EQU_IDX_0_MASK 0xFF
318#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_VFE_EQU_IDX_0_SHIFT 0
319
320#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_VFE_EQU_IDX_1_MASK 0xFF00
321#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_VFE_EQU_IDX_1_SHIFT 8
322
323#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_CRIT_MASK 0x10000
324#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_CRIT_SHIFT 16
325#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_CRIT_MIN 0x00000000
326#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_CRIT_MAX 0x00000001
327
328#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_COMPARE_CRIT_MASK 0xFFFFFFFF
329#define VBIOS_VFE_3X_EQU_ENTRY_PAR0_COMPARE_CRIT_SHIFT 0
330
331#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_QUADRATIC_C1_MASK 0xFFFFFFFF
332#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_QUADRATIC_C1_SHIFT 0
333
334#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_VFE_EQU_IDX_TRUE_MASK 0xFF
335#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_VFE_EQU_IDX_TRUE_SHIFT 0
336
337#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_VFE_EQU_IDX_FALSE_MASK 0xFF00
338#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_VFE_EQU_IDX_FALSE_SHIFT 8
339
340#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_FUNCTION_MASK 0x70000
341#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_FUNCTION_SHIFT 16
342#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_FUNCTION_EQUAL 0x00000000
343#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_FUNCTION_GREATER_EQ 0x00000001
344#define VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_FUNCTION_GREATER 0x00000002
345
346#define VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_MASK 0xF
347#define VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_SHIFT 0
348#define VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_UNITLESS 0x0
349#define VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_FREQ_MHZ 0x1
350#define VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_VOLT_UV 0x2
351#define VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_VF_GAIN 0x3
352#define VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_VOLT_DELTA_UV 0x4
353
354#define NV_VFIELD_DESC_SIZE_BYTE 0x00000000
355#define NV_VFIELD_DESC_SIZE_WORD 0x00000001
356#define NV_VFIELD_DESC_SIZE_DWORD 0x00000002
357#define VFIELD_SIZE(pvregentry) ((pvregentry->strap_reg_desc & 0x18) >> 3)
358
359#define NV_PMU_BIOS_VFIELD_DESC_CODE_INVALID 0x00000000
360#define NV_PMU_BIOS_VFIELD_DESC_CODE_REG 0x00000001
361#define NV_PMU_BIOS_VFIELD_DESC_CODE_INDEX_REG 0x00000002
362
363#define NV_VFIELD_DESC_CODE_INVALID NV_PMU_BIOS_VFIELD_DESC_CODE_INVALID
364#define NV_VFIELD_DESC_CODE_REG NV_PMU_BIOS_VFIELD_DESC_CODE_REG
365#define NV_VFIELD_DESC_CODE_INDEX_REG NV_PMU_BIOS_VFIELD_DESC_CODE_INDEX_REG
366
367#define VFIELD_CODE(pvregentry) ((pvregentry->strap_reg_desc & 0xE0) >> 5)
368
369#define VFIELD_ID_STRAP_IDDQ 0x09
370#define VFIELD_ID_STRAP_IDDQ_1 0x0B
371
372#define VFIELD_REG_HEADER_SIZE 3
373struct vfield_reg_header {
374 u8 version;
375 u8 entry_size;
376 u8 count;
377} __packed;
378
379#define VBIOS_VFIELD_REG_TABLE_VERSION_1_0 0x10
380
381
382#define VFIELD_REG_ENTRY_SIZE 13
383struct vfield_reg_entry {
384 u8 strap_reg_desc;
385 u32 reg;
386 u32 reg_index;
387 u32 index;
388} __packed;
389
390#define VFIELD_HEADER_SIZE 3
391
392struct vfield_header {
393 u8 version;
394 u8 entry_size;
395 u8 count;
396} __packed;
397
398#define VBIOS_VFIELD_TABLE_VERSION_1_0 0x10
399
400#define VFIELD_BIT_START(ventry) (ventry.strap_desc & 0x1F)
401#define VFIELD_BIT_STOP(ventry) ((ventry.strap_desc & 0x3E0) >> 5)
402#define VFIELD_BIT_REG(ventry) ((ventry.strap_desc & 0x3C00) >> 10)
403
404#define VFIELD_ENTRY_SIZE 3
405
406struct vfield_entry {
407 u8 strap_id;
408 u16 strap_desc;
409} __packed;
410
411#define PERF_CLK_DOMAINS_IDX_MAX (32)
412#define PERF_CLK_DOMAINS_IDX_INVALID PERF_CLK_DOMAINS_IDX_MAX
413
414#define VBIOS_PSTATE_TABLE_VERSION_5X 0x50
415#define VBIOS_PSTATE_HEADER_5X_SIZE_10 (10)
416
417struct vbios_pstate_header_5x {
418 u8 version;
419 u8 header_size;
420 u8 base_entry_size;
421 u8 base_entry_count;
422 u8 clock_entry_size;
423 u8 clock_entry_count;
424 u8 flags0;
425 u8 initial_pstate;
426 u8 cpi_support_level;
427u8 cpi_features;
428} __packed;
429
430#define VBIOS_PSTATE_CLOCK_ENTRY_5X_SIZE_6 6
431
432#define VBIOS_PSTATE_BASE_ENTRY_5X_SIZE_2 0x2
433#define VBIOS_PSTATE_BASE_ENTRY_5X_SIZE_3 0x3
434
435struct vbios_pstate_entry_clock_5x {
436 u16 param0;
437 u32 param1;
438} __packed;
439
440struct vbios_pstate_entry_5x {
441 u8 pstate_level;
442 u8 flags0;
443 u8 lpwr_entry_idx;
444 struct vbios_pstate_entry_clock_5x clockEntry[PERF_CLK_DOMAINS_IDX_MAX];
445} __packed;
446
447#define VBIOS_PSTATE_5X_CLOCK_PROG_PARAM0_NOM_FREQ_MHZ_SHIFT 0
448#define VBIOS_PSTATE_5X_CLOCK_PROG_PARAM0_NOM_FREQ_MHZ_MASK 0x00003FFF
449
450#define VBIOS_PSTATE_5X_CLOCK_PROG_PARAM1_MIN_FREQ_MHZ_SHIFT 0
451#define VBIOS_PSTATE_5X_CLOCK_PROG_PARAM1_MIN_FREQ_MHZ_MASK 0x00003FFF
452
453#define VBIOS_PSTATE_5X_CLOCK_PROG_PARAM1_MAX_FREQ_MHZ_SHIFT 14
454#define VBIOS_PSTATE_5X_CLOCK_PROG_PARAM1_MAX_FREQ_MHZ_MASK 0x0FFFC000
455
456#define VBIOS_PERFLEVEL_SKIP_ENTRY 0xFF
457
458#define VBIOS_MEMORY_CLOCK_HEADER_11_VERSION 0x11
459
460#define VBIOS_MEMORY_CLOCK_HEADER_11_0_SIZE 16
461#define VBIOS_MEMORY_CLOCK_HEADER_11_1_SIZE 21
462#define VBIOS_MEMORY_CLOCK_HEADER_11_2_SIZE 26
463
464struct vbios_memory_clock_header_1x {
465 u8 version;
466 u8 header_size;
467 u8 base_entry_size;
468 u8 strap_entry_size;
469 u8 strap_entry_count;
470 u8 entry_count;
471 u8 flags;
472 u8 fbvdd_settle_time;
473 u32 cfg_pwrd_val;
474 u16 fbvddq_high;
475 u16 fbvddq_low;
476 u32 script_list_ptr;
477 u8 script_list_count;
478 u32 cmd_script_list_ptr;
479 u8 cmd_script_list_count;
480} __packed;
481
482#define VBIOS_MEMORY_CLOCK_BASE_ENTRY_11_2_SIZE 20
483
484struct vbios_memory_clock_base_entry_11 {
485 u16 minimum;
486 u16 maximum;
487 u32 script_pointer;
488 u8 flags0;
489 u32 fbpa_config;
490 u32 fbpa_config1;
491 u8 flags1;
492 u8 ref_mpllssf_freq_delta;
493 u8 flags2;
494} __packed;
495
496/* Script Pointer Index */
497/* #define VBIOS_MEMORY_CLOCK_BASE_ENTRY_11_FLAGS1_SCRIPT_INDEX 3:2*/
498#define VBIOS_MEMORY_CLOCK_BASE_ENTRY_11_FLAGS1_SCRIPT_INDEX_MASK 0xc
499#define VBIOS_MEMORY_CLOCK_BASE_ENTRY_11_FLAGS1_SCRIPT_INDEX_SHIFT 2
500/* #define VBIOS_MEMORY_CLOCK_BASE_ENTRY_12_FLAGS2_CMD_SCRIPT_INDEX 1:0*/
501#define VBIOS_MEMORY_CLOCK_BASE_ENTRY_12_FLAGS2_CMD_SCRIPT_INDEX_MASK 0x3
502#define VBIOS_MEMORY_CLOCK_BASE_ENTRY_12_FLAGS2_CMD_SCRIPT_INDEX_SHIFT 0
503
504#define VBIOS_POWER_SENSORS_VERSION_2X 0x20
505#define VBIOS_POWER_SENSORS_2X_HEADER_SIZE_08 0x00000008
506
507struct pwr_sensors_2x_header {
508 u8 version;
509 u8 header_size;
510 u8 table_entry_size;
511 u8 num_table_entries;
512 u32 ba_script_pointer;
513};
514
515#define VBIOS_POWER_SENSORS_2X_ENTRY_SIZE_15 0x00000015
516
517struct pwr_sensors_2x_entry {
518 u8 flags0;
519 u32 class_param0;
520 u32 sensor_param0;
521 u32 sensor_param1;
522 u32 sensor_param2;
523 u32 sensor_param3;
524};
525
526#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_FLAGS0_CLASS_MASK 0xF
527#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_FLAGS0_CLASS_SHIFT 0
528#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_FLAGS0_CLASS_I2C 0x00000001
529
530#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_CLASS_PARAM0_I2C_INDEX_MASK 0xFF
531#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_CLASS_PARAM0_I2C_INDEX_SHIFT 0
532#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_CLASS_PARAM0_I2C_USE_FXP8_8_MASK 0x100
533#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_CLASS_PARAM0_I2C_USE_FXP8_8_SHIFT 8
534
535#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM0_INA3221_RSHUNT0_MOHM_MASK 0xFFFF
536#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM0_INA3221_RSHUNT0_MOHM_SHIFT 0
537#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM0_INA3221_RSHUNT1_MOHM_MASK 0xFFFF0000
538#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM0_INA3221_RSHUNT1_MOHM_SHIFT 16
539#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM1_INA3221_RSHUNT2_MOHM_MASK 0xFFFF
540#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM1_INA3221_RSHUNT2_MOHM_SHIFT 0
541#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM1_INA3221_CONFIGURATION_MASK 0xFFFF0000
542#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM1_INA3221_CONFIGURATION_SHIFT 16
543
544#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM2_INA3221_MASKENABLE_MASK 0xFFFF
545#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM2_INA3221_MASKENABLE_SHIFT 0
546#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM2_INA3221_GPIOFUNCTION_MASK 0xFF0000
547#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM2_INA3221_GPIOFUNCTION_SHIFT 16
548#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM3_INA3221_CURR_CORRECT_M_MASK 0xFFFF
549#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM3_INA3221_CURR_CORRECT_M_SHIFT 0
550#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM3_INA3221_CURR_CORRECT_B_MASK 0xFFFF0000
551#define NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM3_INA3221_CURR_CORRECT_B_SHIFT 16
552
553#define VBIOS_POWER_TOPOLOGY_VERSION_2X 0x20
554#define VBIOS_POWER_TOPOLOGY_2X_HEADER_SIZE_06 0x00000006
555
556struct pwr_topology_2x_header {
557 u8 version;
558 u8 header_size;
559 u8 table_entry_size;
560 u8 num_table_entries;
561 u8 rel_entry_size;
562 u8 num_rel_entries;
563};
564
565#define VBIOS_POWER_TOPOLOGY_2X_ENTRY_SIZE_16 0x00000016
566
567struct pwr_topology_2x_entry {
568 u8 flags0;
569 u8 pwr_rail;
570 u32 param0;
571 u32 curr_corr_slope;
572 u32 curr_corr_offset;
573 u32 param1;
574 u32 param2;
575};
576
577#define NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_FLAGS0_CLASS_MASK 0xF
578#define NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_FLAGS0_CLASS_SHIFT 0
579#define NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_FLAGS0_CLASS_SENSOR 0x00000001
580
581#define NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_PARAM1_SENSOR_INDEX_MASK 0xFF
582#define NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_PARAM1_SENSOR_INDEX_SHIFT 0
583#define NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_PARAM1_SENSOR_PROVIDER_INDEX_MASK 0xFF00
584#define NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_PARAM1_SENSOR_PROVIDER_INDEX_SHIFT 8
585
586#define VBIOS_POWER_POLICY_VERSION_3X 0x30
587#define VBIOS_POWER_POLICY_3X_HEADER_SIZE_25 0x00000025
588
589struct pwr_policy_3x_header_struct {
590 u8 version;
591 u8 header_size;
592 u8 table_entry_size;
593 u8 num_table_entries;
594 u16 base_sample_period;
595 u16 min_client_sample_period;
596 u8 table_rel_entry_size;
597 u8 num_table_rel_entries;
598 u8 tgp_policy_idx;
599 u8 rtp_policy_idx;
600 u8 mxm_policy_idx;
601 u8 dnotifier_policy_idx;
602 u32 d2_limit;
603 u32 d3_limit;
604 u32 d4_limit;
605 u32 d5_limit;
606 u8 low_sampling_mult;
607 u8 pwr_tgt_policy_idx;
608 u8 pwr_tgt_floor_policy_idx;
609 u8 sm_bus_policy_idx;
610 u8 table_viol_entry_size;
611 u8 num_table_viol_entries;
612};
613
614#define VBIOS_POWER_POLICY_3X_ENTRY_SIZE_2E 0x0000002E
615
616struct pwr_policy_3x_entry_struct {
617 u8 flags0;
618 u8 ch_idx;
619 u32 limit_min;
620 u32 limit_rated;
621 u32 limit_max;
622 u32 param0;
623 u32 param1;
624 u32 param2;
625 u32 param3;
626 u32 limit_batt;
627 u8 flags1;
628 u8 past_length;
629 u8 next_length;
630 u16 ratio_min;
631 u16 ratio_max;
632 u8 sample_mult;
633 u32 filter_param;
634};
635
636#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS0_CLASS_MASK 0xF
637#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS0_CLASS_SHIFT 0
638#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS0_CLASS_HW_THRESHOLD 0x00000005
639#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS0_LIMIT_UNIT_MASK 0x10
640#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS0_LIMIT_UNIT_SHIFT 4
641
642#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS1_FULL_DEFLECTION_LIMIT_MASK 0x1
643#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS1_FULL_DEFLECTION_LIMIT_SHIFT 0
644#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS1_INTEGRAL_CONTROL_MASK 0x2
645#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS1_INTEGRAL_CONTROL_SHIFT 1
646#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS1_FILTER_TYPE_MASK 0x3C
647#define NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS1_FILTER_TYPE_SHIFT 2
648
649#define NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM0_HW_THRESHOLD_THRES_IDX_MASK 0xFF
650#define NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM0_HW_THRESHOLD_THRES_IDX_SHIFT 0
651#define NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM0_HW_THRESHOLD_LOW_THRESHOLD_IDX_MASK 0xFF00
652#define NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM0_HW_THRESHOLD_LOW_THRESHOLD_IDX_SHIFT 8
653#define NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM0_HW_THRESHOLD_LOW_THRESHOLD_USE_MASK 0x10000
654#define NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM0_HW_THRESHOLD_LOW_THRESHOLD_USE_SHIFT 16
655
656#define NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM1_HW_THRESHOLD_LOW_THRESHOLD_VAL_MASK 0xFFFF
657#define NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM1_HW_THRESHOLD_LOW_THRESHOLD_VAL_SHIFT 0
658
659/* Voltage Rail Table */
660struct vbios_voltage_rail_table_1x_header {
661 u8 version;
662 u8 header_size;
663 u8 table_entry_size;
664 u8 num_table_entries;
665 u8 volt_domain_hal;
666} __packed;
667
668#define NV_VBIOS_VOLTAGE_RAIL_1X_ENTRY_SIZE_07 0X00000007
669#define NV_VBIOS_VOLTAGE_RAIL_1X_ENTRY_SIZE_08 0X00000008
670#define NV_VBIOS_VOLTAGE_RAIL_1X_ENTRY_SIZE_09 0X00000009
671#define NV_VBIOS_VOLTAGE_RAIL_1X_ENTRY_SIZE_0A 0X0000000A
672#define NV_VBIOS_VOLTAGE_RAIL_1X_ENTRY_SIZE_0B 0X0000000B
673
674struct vbios_voltage_rail_table_1x_entry {
675 u32 boot_voltage_uv;
676 u8 rel_limit_vfe_equ_idx;
677 u8 alt_rel_limit_vfe_equidx;
678 u8 ov_limit_vfe_equ_idx;
679 u8 pwr_equ_idx;
680 u8 boot_volt_vfe_equ_idx;
681 u8 vmin_limit_vfe_equ_idx;
682 u8 volt_margin_limit_vfe_equ_idx;
683} __packed;
684
685/* Voltage Device Table */
686struct vbios_voltage_device_table_1x_header {
687 u8 version;
688 u8 header_size;
689 u8 table_entry_size;
690 u8 num_table_entries;
691};
692
693struct vbios_voltage_device_table_1x_entry {
694 u8 type;
695 u8 volt_domain;
696 u16 settle_time_us;
697 u32 param0;
698 u32 param1;
699 u32 param2;
700 u32 param3;
701 u32 param4;
702};
703
704#define NV_VBIOS_VOLTAGE_DEVICE_1X_ENTRY_TYPE_INVALID 0x00
705#define NV_VBIOS_VOLTAGE_DEVICE_1X_ENTRY_TYPE_PSV 0x02
706
707#define NV_VBIOS_VDT_1X_ENTRY_PARAM0_PSV_INPUT_FREQUENCY_MASK \
708 GENMASK(23, 0)
709#define NV_VBIOS_VDT_1X_ENTRY_PARAM0_PSV_INPUT_FREQUENCY_SHIFT 0
710#define NV_VBIOS_VDT_1X_ENTRY_PARAM0_PSV_EXT_DEVICE_INDEX_MASK \
711 GENMASK(31, 24)
712#define NV_VBIOS_VDT_1X_ENTRY_PARAM0_PSV_EXT_DEVICE_INDEX_SHIFT 24
713
714#define NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_VOLTAGE_MINIMUM_MASK \
715 GENMASK(23, 0)
716#define NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_VOLTAGE_MINIMUM_SHIFT 0
717#define NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_OPERATION_TYPE_MASK \
718 GENMASK(31, 24)
719#define NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_OPERATION_TYPE_SHIFT 24
720#define NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_OPERATION_TYPE_DEFAULT 0x00
721#define NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_OPERATION_TYPE_LPWR_STEADY_STATE \
722 0x01
723#define NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_OPERATION_TYPE_LPWR_SLEEP_STATE \
724 0x02
725#define NV_VBIOS_VDT_1X_ENTRY_PARAM2_PSV_VOLTAGE_MAXIMUM_MASK \
726 GENMASK(23, 0)
727#define NV_VBIOS_VDT_1X_ENTRY_PARAM2_PSV_VOLTAGE_MAXIMUM_SHIFT 0
728#define NV_VBIOS_VDT_1X_ENTRY_PARAM2_PSV_RSVD_MASK \
729 GENMASK(31, 24)
730#define NV_VBIOS_VDT_1X_ENTRY_PARAM2_PSV_RSVD_SHIFT 24
731
732#define NV_VBIOS_VDT_1X_ENTRY_PARAM3_PSV_VOLTAGE_BASE_MASK \
733 GENMASK(23, 0)
734#define NV_VBIOS_VDT_1X_ENTRY_PARAM3_PSV_VOLTAGE_BASE_SHIFT 0
735#define NV_VBIOS_VDT_1X_ENTRY_PARAM3_PSV_VOLTAGE_STEPS_MASK \
736 GENMASK(31, 24)
737#define NV_VBIOS_VDT_1X_ENTRY_PARAM3_PSV_VOLTAGE_STEPS_SHIFT 24
738
739#define NV_VBIOS_VDT_1X_ENTRY_PARAM4_PSV_OFFSET_SCALE_MASK \
740 GENMASK(23, 0)
741#define NV_VBIOS_VDT_1X_ENTRY_PARAM4_PSV_OFFSET_SCALE_SHIFT 0
742#define NV_VBIOS_VDT_1X_ENTRY_PARAM4_PSV_RSVD_MASK \
743 GENMASK(31, 24)
744#define NV_VBIOS_VDT_1X_ENTRY_PARAM4_PSV_RSVD_SHIFT 24
745
746/* Voltage Policy Table */
747struct vbios_voltage_policy_table_1x_header {
748 u8 version;
749 u8 header_size;
750 u8 table_entry_size;
751 u8 num_table_entries;
752 u8 perf_core_vf_seq_policy_idx;
753};
754
755struct vbios_voltage_policy_table_1x_entry {
756 u8 type;
757 u32 param0;
758 u32 param1;
759};
760
761#define NV_VBIOS_VOLTAGE_POLICY_1X_ENTRY_TYPE_INVALID 0x00
762#define NV_VBIOS_VOLTAGE_POLICY_1X_ENTRY_TYPE_SINGLE_RAIL 0x01
763#define NV_VBIOS_VOLTAGE_POLICY_1X_ENTRY_TYPE_SR_MULTI_STEP 0x02
764#define NV_VBIOS_VOLTAGE_POLICY_1X_ENTRY_TYPE_SR_SINGLE_STEP 0x03
765
766#define NV_VBIOS_VPT_ENTRY_PARAM0_SINGLE_RAIL_VOLT_DOMAIN_MASK \
767 GENMASK(7, 0)
768#define NV_VBIOS_VPT_ENTRY_PARAM0_SINGLE_RAIL_VOLT_DOMAIN_SHIFT 0
769#define NV_VBIOS_VPT_ENTRY_PARAM0_RSVD_MASK GENMASK(8, 31)
770#define NV_VBIOS_VPT_ENTRY_PARAM0_RSVD_SHIFT 8
771
772#define NV_VBIOS_VPT_ENTRY_PARAM0_SR_VD_MASTER_MASK \
773 GENMASK(7, 0)
774#define NV_VBIOS_VPT_ENTRY_PARAM0_SR_VD_MASTER_SHIFT 0
775#define NV_VBIOS_VPT_ENTRY_PARAM0_SR_VD_SLAVE_MASK \
776 GENMASK(15, 8)
777#define NV_VBIOS_VPT_ENTRY_PARAM0_SR_VD_SLAVE_SHIFT 8
778#define NV_VBIOS_VPT_ENTRY_PARAM0_SR_DELTA_SM_MIN_MASK \
779 GENMASK(23, 16)
780#define NV_VBIOS_VPT_ENTRY_PARAM0_SR_DELTA_SM_MIN_SHIFT 16
781#define NV_VBIOS_VPT_ENTRY_PARAM0_SR_DELTA_SM_MAX_MASK \
782 GENMASK(31, 24)
783#define NV_VBIOS_VPT_ENTRY_PARAM0_SR_DELTA_SM_MAX_SHIFT 24
784
785/* Type-Specific Parameter DWORD 0 - Type = _SR_MULTI_STEP */
786#define NV_VBIOS_VPT_ENTRY_PARAM1_SR_SETTLE_TIME_INTERMEDIATE_MASK \
787 GENMASK(15, 0)
788#define NV_VBIOS_VPT_ENTRY_PARAM1_SR_SETTLE_TIME_INTERMEDIATE_SHIFT \
789 0
790
791#define VBIOS_THERM_DEVICE_VERSION_1X 0x10
792
793#define VBIOS_THERM_DEVICE_1X_HEADER_SIZE_04 0x00000004
794
795struct therm_device_1x_header {
796 u8 version;
797 u8 header_size;
798 u8 table_entry_size;
799 u8 num_table_entries;
800} ;
801
802struct therm_device_1x_entry {
803 u8 class_id;
804 u8 param0;
805 u8 flags;
806} ;
807
808#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU 0x01
809
810#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_PARAM0_I2C_DEVICE_INDEX_MASK 0xFF
811#define NV_VBIOS_THERM_DEVICE_1X_ENTRY_PARAM0_I2C_DEVICE_INDEX_SHIFT 0
812
813#define VBIOS_THERM_CHANNEL_VERSION_1X 0x10
814
815#define VBIOS_THERM_CHANNEL_1X_HEADER_SIZE_09 0x00000009
816
817struct therm_channel_1x_header {
818 u8 version;
819 u8 header_size;
820 u8 table_entry_size;
821 u8 num_table_entries;
822 u8 gpu_avg_pri_ch_idx;
823 u8 gpu_max_pri_ch_idx;
824 u8 board_pri_ch_idx;
825 u8 mem_pri_ch_idx;
826 u8 pwr_supply_pri_ch_idx;
827};
828
829struct therm_channel_1x_entry {
830 u8 class_id;
831 u8 param0;
832 u8 param1;
833 u8 param2;
834 u8 flags;
835};
836
837#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_CLASS_DEVICE 0x01
838
839#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_PARAM0_DEVICE_INDEX_MASK 0xFF
840#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_PARAM0_DEVICE_INDEX_SHIFT 0
841
842#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_PARAM1_DEVICE_PROVIDER_INDEX_MASK 0xFF
843#define NV_VBIOS_THERM_CHANNEL_1X_ENTRY_PARAM1_DEVICE_PROVIDER_INDEX_SHIFT 0
844
845/* Frequency Controller Table */
846struct vbios_fct_1x_header {
847 u8 version;
848 u8 header_size;
849 u8 entry_size;
850 u8 entry_count;
851 u16 sampling_period_ms;
852} __packed;
853
854struct vbios_fct_1x_entry {
855 u8 flags0;
856 u8 clk_domain_idx;
857 u16 param0;
858 u16 param1;
859 u32 param2;
860 u32 param3;
861 u32 param4;
862 u32 param5;
863 u32 param6;
864 u32 param7;
865 u32 param8;
866} __packed;
867
868#define NV_VBIOS_FCT_1X_ENTRY_FLAGS0_TYPE_MASK GENMASK(3, 0)
869#define NV_VBIOS_FCT_1X_ENTRY_FLAGS0_TYPE_SHIFT 0
870#define NV_VBIOS_FCT_1X_ENTRY_FLAGS0_TYPE_DISABLED 0x0
871#define NV_VBIOS_FCT_1X_ENTRY_FLAGS0_TYPE_PI 0x1
872
873#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_MASK GENMASK(7, 0)
874#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_SHIFT 0
875#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_SYS 0x00
876#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_LTC 0x01
877#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_XBAR 0x02
878#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_GPC0 0x03
879#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_GPC1 0x04
880#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_GPC2 0x05
881#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_GPC3 0x06
882#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_GPC4 0x07
883#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_GPC5 0x08
884#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_ID_GPCS 0x09
885
886#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_FREQ_MODE_MASK GENMASK(9, 8)
887#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_FREQ_MODE_SHIFT 8
888#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_FREQ_MODE_BCAST 0x0
889#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_FREQ_MODE_MIN 0x1
890#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_FREQ_MODE_MAX 0x2
891#define NV_VBIOS_FCT_1X_ENTRY_PARAM0_FREQ_MODE_AVG 0x3
892
893#define NV_VBIOS_FCT_1X_ENTRY_PARAM1_SLOWDOWN_PCT_MIN_MASK GENMASK(7, 0)
894#define NV_VBIOS_FCT_1X_ENTRY_PARAM1_SLOWDOWN_PCT_MIN_SHIFT 0
895
896#define NV_VBIOS_FCT_1X_ENTRY_PARAM1_POISON_MASK GENMASK(8, 8)
897#define NV_VBIOS_FCT_1X_ENTRY_PARAM1_POISON_SHIFT 8
898#define NV_VBIOS_FCT_1X_ENTRY_PARAM1_POISON_NO 0x0
899#define NV_VBIOS_FCT_1X_ENTRY_PARAM1_POISON_YES 0x1
900
901#define NV_VBIOS_FCT_1X_ENTRY_PARAM2_PROP_GAIN_MASK GENMASK(31, 0)
902#define NV_VBIOS_FCT_1X_ENTRY_PARAM2_PROP_GAIN_SHIFT 0
903
904#define NV_VBIOS_FCT_1X_ENTRY_PARAM3_INTEG_GAIN_MASK GENMASK(31, 0)
905#define NV_VBIOS_FCT_1X_ENTRY_PARAM3_INTEG_GAIN_SHIFT 0
906
907
908#define NV_VBIOS_FCT_1X_ENTRY_PARAM4_INTEG_DECAY_MASK GENMASK(31, 0)
909#define NV_VBIOS_FCT_1X_ENTRY_PARAM4_INTEG_DECAY_SHIFT 0
910
911#define NV_VBIOS_FCT_1X_ENTRY_PARAM5_VOLT_DELTA_MIN_MASK GENMASK(31, 0)
912#define NV_VBIOS_FCT_1X_ENTRY_PARAM5_VOLT_DELTA_MIN_SHIFT 0
913
914
915#define NV_VBIOS_FCT_1X_ENTRY_PARAM6_VOLT_DELTA_MAX_MASK GENMASK(31, 0)
916#define NV_VBIOS_FCT_1X_ENTRY_PARAM6_VOLT_DELTA_MAX_SHIFT 0
917
918#define NV_VBIOS_FCT_1X_ENTRY_PARAM7_FREQ_CAP_VF_MASK GENMASK(15, 0)
919#define NV_VBIOS_FCT_1X_ENTRY_PARAM7_FREQ_CAP_VF_SHIFT 0
920#define NV_VBIOS_FCT_1X_ENTRY_PARAM7_FREQ_CAP_VMIN_MASK GENMASK(31, 16)
921#define NV_VBIOS_FCT_1X_ENTRY_PARAM7_FREQ_CAP_VMIN_SHIFT 16
922
923#define NV_VBIOS_FCT_1X_ENTRY_PARAM8_FREQ_HYST_POS_MASK GENMASK(15, 0)
924#define NV_VBIOS_FCT_1X_ENTRY_PARAM8_FREQ_HYST_POS_SHIFT 0
925#define NV_VBIOS_FCT_1X_ENTRY_PARAM8_FREQ_HYST_NEG_MASK GENMASK(31, 16)
926#define NV_VBIOS_FCT_1X_ENTRY_PARAM8_FREQ_HYST_NEG_SHIFT 16
927
928/* LPWR Index Table */
929struct nvgpu_bios_lpwr_idx_table_1x_header {
930 u8 version;
931 u8 header_size;
932 u8 entry_size;
933 u8 entry_count;
934 u16 base_sampling_period;
935} __packed;
936
937struct nvgpu_bios_lpwr_idx_table_1x_entry {
938 u8 pcie_idx;
939 u8 gr_idx;
940 u8 ms_idx;
941 u8 di_idx;
942 u8 gc6_idx;
943} __packed;
944
945/* LPWR MS Table*/
946struct nvgpu_bios_lpwr_ms_table_1x_header {
947 u8 version;
948 u8 header_size;
949 u8 entry_size;
950 u8 entry_count;
951 u8 default_entry_idx;
952 u16 idle_threshold_us;
953} __packed;
954
955struct nvgpu_bios_lpwr_ms_table_1x_entry {
956 u32 feautre_mask;
957 u16 dynamic_current_logic;
958 u16 dynamic_current_sram;
959} __packed;
960
961#define NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_MASK GENMASK(0, 0)
962#define NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_SHIFT 0
963#define NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_SWASR_MASK GENMASK(2, 2)
964#define NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_SWASR_SHIFT 2
965#define NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_CLOCK_GATING_MASK \
966 GENMASK(3, 3)
967#define NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_CLOCK_GATING_SHIFT 3
968#define NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_RPPG_MASK GENMASK(5, 5)
969#define NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_RPPG_SHIFT 5
970
971/* LPWR GR Table */
972struct nvgpu_bios_lpwr_gr_table_1x_header {
973 u8 version;
974 u8 header_size;
975 u8 entry_size;
976 u8 entry_count;
977 u8 default_entry_idx;
978 u16 idle_threshold_us;
979 u8 adaptive_gr_multiplier;
980} __packed;
981
982struct nvgpu_bios_lpwr_gr_table_1x_entry {
983 u32 feautre_mask;
984} __packed;
985
986#define NV_VBIOS_LPWR_GR_FEATURE_MASK_GR_MASK GENMASK(0, 0)
987#define NV_VBIOS_LPWR_GR_FEATURE_MASK_GR_SHIFT 0
988
989#define NV_VBIOS_LPWR_GR_FEATURE_MASK_GR_RPPG_MASK GENMASK(4, 4)
990#define NV_VBIOS_LPWR_GR_FEATURE_MASK_GR_RPPG_SHIFT 4
991
992#endif
diff --git a/drivers/gpu/nvgpu/lpwr/lpwr.c b/drivers/gpu/nvgpu/lpwr/lpwr.c
new file mode 100644
index 00000000..4f8d2eec
--- /dev/null
+++ b/drivers/gpu/nvgpu/lpwr/lpwr.c
@@ -0,0 +1,423 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "gk20a/pmu_gk20a.h"
16#include "gp106/pmu_gp106.h"
17#include "gk20a/pmu_api.h"
18#include "gm206/bios_gm206.h"
19#include "pstate/pstate.h"
20#include "include/bios.h"
21#include "perf/perf.h"
22#include "lpwr.h"
23
24static int get_lpwr_idx_table(struct gk20a *g)
25{
26 u32 *lpwr_idx_table_ptr;
27 u8 *entry_addr;
28 u32 idx;
29 struct nvgpu_lpwr_bios_idx_data *pidx_data =
30 &g->perf_pmu.lpwr.lwpr_bios_data.idx;
31 struct nvgpu_bios_lpwr_idx_table_1x_header header = { 0 };
32 struct nvgpu_bios_lpwr_idx_table_1x_entry entry = { 0 };
33
34 if (g->ops.bios.get_perf_table_ptrs) {
35 lpwr_idx_table_ptr = (u32 *)g->ops.bios.get_perf_table_ptrs(g,
36 g->bios.perf_token, LOWPOWER_TABLE);
37 if (lpwr_idx_table_ptr == NULL)
38 return -EINVAL;
39 } else
40 return -EINVAL;
41
42 memcpy(&header, lpwr_idx_table_ptr,
43 sizeof(struct nvgpu_bios_lpwr_idx_table_1x_header));
44
45 if (header.entry_count >= LPWR_VBIOS_IDX_ENTRY_COUNT_MAX)
46 return -EINVAL;
47
48 pidx_data->base_sampling_period = (u16)header.base_sampling_period;
49
50 /* Parse the LPWR Index Table entries.*/
51 for (idx = 0; idx < header.entry_count; idx++) {
52 entry_addr = (u8 *)lpwr_idx_table_ptr + header.header_size +
53 (idx * header.entry_size);
54
55 memcpy(&entry, entry_addr,
56 sizeof(struct nvgpu_bios_lpwr_idx_table_1x_entry));
57
58 pidx_data->entry[idx].pcie_idx = entry.pcie_idx;
59 pidx_data->entry[idx].gr_idx = entry.gr_idx;
60 pidx_data->entry[idx].ms_idx = entry.ms_idx;
61 pidx_data->entry[idx].di_idx = entry.di_idx;
62 pidx_data->entry[idx].gc6_idx = entry.gc6_idx;
63
64 }
65
66 return 0;
67}
68
69static int get_lpwr_gr_table(struct gk20a *g)
70{
71 u32 *lpwr_gr_table_ptr;
72 u8 *entry_addr;
73 u32 idx;
74 struct nvgpu_lpwr_bios_gr_data *pgr_data =
75 &g->perf_pmu.lpwr.lwpr_bios_data.gr;
76 struct nvgpu_bios_lpwr_gr_table_1x_header header = { 0 };
77 struct nvgpu_bios_lpwr_gr_table_1x_entry entry = { 0 };
78
79 if (g->ops.bios.get_perf_table_ptrs) {
80 lpwr_gr_table_ptr = (u32 *)g->ops.bios.get_perf_table_ptrs(g,
81 g->bios.perf_token, LOWPOWER_GR_TABLE);
82 if (lpwr_gr_table_ptr == NULL)
83 return -EINVAL;
84 } else
85 return -EINVAL;
86
87 memcpy(&header, lpwr_gr_table_ptr,
88 sizeof(struct nvgpu_bios_lpwr_gr_table_1x_header));
89
90 /* Parse the LPWR Index Table entries.*/
91 for (idx = 0; idx < header.entry_count; idx++) {
92 entry_addr = (u8 *)lpwr_gr_table_ptr + header.header_size +
93 (idx * header.entry_size);
94
95 memcpy(&entry, entry_addr,
96 sizeof(struct nvgpu_bios_lpwr_gr_table_1x_entry));
97
98 if (BIOS_GET_FIELD(entry.feautre_mask,
99 NV_VBIOS_LPWR_MS_FEATURE_MASK_MS)) {
100 pgr_data->entry[idx].gr_enabled = true;
101
102 pgr_data->entry[idx].feature_mask =
103 NVGPU_PMU_GR_FEATURE_MASK_ALL;
104
105 if (!BIOS_GET_FIELD(entry.feautre_mask,
106 NV_VBIOS_LPWR_GR_FEATURE_MASK_GR_RPPG))
107 pgr_data->entry[idx].feature_mask &=
108 ~NVGPU_PMU_GR_FEATURE_MASK_RPPG;
109 }
110
111 }
112
113 return 0;
114}
115
116static int get_lpwr_ms_table(struct gk20a *g)
117{
118 u32 *lpwr_ms_table_ptr;
119 u8 *entry_addr;
120 u32 idx;
121 struct nvgpu_lpwr_bios_ms_data *pms_data =
122 &g->perf_pmu.lpwr.lwpr_bios_data.ms;
123 struct nvgpu_bios_lpwr_ms_table_1x_header header = { 0 };
124 struct nvgpu_bios_lpwr_ms_table_1x_entry entry = { 0 };
125
126 if (g->ops.bios.get_perf_table_ptrs) {
127 lpwr_ms_table_ptr = (u32 *)g->ops.bios.get_perf_table_ptrs(g,
128 g->bios.perf_token, LOWPOWER_MS_TABLE);
129 if (lpwr_ms_table_ptr == NULL)
130 return -EINVAL;
131 } else
132 return -EINVAL;
133
134 memcpy(&header, lpwr_ms_table_ptr,
135 sizeof(struct nvgpu_bios_lpwr_ms_table_1x_header));
136
137 if (header.entry_count >= LPWR_VBIOS_MS_ENTRY_COUNT_MAX)
138 return -EINVAL;
139
140 pms_data->default_entry_idx = (u8)header.default_entry_idx;
141
142 pms_data->idle_threshold_us = (u32)(header.idle_threshold_us * 10);
143
144 /* Parse the LPWR MS Table entries.*/
145 for (idx = 0; idx < header.entry_count; idx++) {
146 entry_addr = (u8 *)lpwr_ms_table_ptr + header.header_size +
147 (idx * header.entry_size);
148
149 memcpy(&entry, entry_addr,
150 sizeof(struct nvgpu_bios_lpwr_ms_table_1x_entry));
151
152 if (BIOS_GET_FIELD(entry.feautre_mask,
153 NV_VBIOS_LPWR_MS_FEATURE_MASK_MS)) {
154 pms_data->entry[idx].ms_enabled = true;
155
156 pms_data->entry[idx].feature_mask =
157 NVGPU_PMU_MS_FEATURE_MASK_ALL;
158
159 if (!BIOS_GET_FIELD(entry.feautre_mask,
160 NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_CLOCK_GATING))
161 pms_data->entry[idx].feature_mask &=
162 ~NVGPU_PMU_MS_FEATURE_MASK_CLOCK_GATING;
163
164 if (!BIOS_GET_FIELD(entry.feautre_mask,
165 NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_SWASR))
166 pms_data->entry[idx].feature_mask &=
167 ~NVGPU_PMU_MS_FEATURE_MASK_SW_ASR;
168
169 if (!BIOS_GET_FIELD(entry.feautre_mask,
170 NV_VBIOS_LPWR_MS_FEATURE_MASK_MS_RPPG))
171 pms_data->entry[idx].feature_mask &=
172 ~NVGPU_PMU_MS_FEATURE_MASK_RPPG;
173 }
174
175 pms_data->entry[idx].dynamic_current_logic =
176 entry.dynamic_current_logic;
177
178 pms_data->entry[idx].dynamic_current_sram =
179 entry.dynamic_current_sram;
180 }
181
182 return 0;
183}
184
185u32 nvgpu_lpwr_pg_setup(struct gk20a *g)
186{
187 u32 err = 0;
188
189 gk20a_dbg_fn("");
190
191 err = get_lpwr_gr_table(g);
192 if (err)
193 return err;
194
195 err = get_lpwr_ms_table(g);
196 if (err)
197 return err;
198
199 err = get_lpwr_idx_table(g);
200
201 return err;
202}
203
204static void nvgpu_pmu_handle_param_lpwr_msg(struct gk20a *g,
205 struct pmu_msg *msg, void *param,
206 u32 handle, u32 status)
207{
208 u32 *ack_status = param;
209
210 gk20a_dbg_fn("");
211
212 if (status != 0) {
213 gk20a_err(dev_from_gk20a(g), "LWPR PARAM cmd aborted");
214 return;
215 }
216
217 *ack_status = 1;
218
219 gp106_dbg_pmu("lpwr-param is acknowledged from PMU %x",
220 msg->msg.pg.msg_type);
221}
222
223int nvgpu_lwpr_mclk_change(struct gk20a *g, u32 pstate)
224{
225 struct pmu_cmd cmd;
226 u32 seq, status = 0;
227 u32 payload = NV_PMU_PG_PARAM_MCLK_CHANGE_MS_SWASR_ENABLED;
228 struct clk_set_info *pstate_info;
229 u32 ack_status = 0;
230
231 gk20a_dbg_fn("");
232
233 pstate_info = pstate_get_clk_set_info(g, pstate,
234 clkwhich_mclk);
235 if (!pstate_info)
236 return -EINVAL;
237
238 if (pstate_info->max_mhz >
239 MAX_SWASR_MCLK_FREQ_WITHOUT_WR_TRAINING_MAXWELL_MHZ)
240 payload |=
241 NV_PMU_PG_PARAM_MCLK_CHANGE_GDDR5_WR_TRAINING_ENABLED;
242
243 if (payload != g->perf_pmu.lpwr.mclk_change_cache) {
244 g->perf_pmu.lpwr.mclk_change_cache = payload;
245
246 cmd.hdr.unit_id = PMU_UNIT_PG;
247 cmd.hdr.size = PMU_CMD_HDR_SIZE +
248 sizeof(struct pmu_pg_cmd_mclk_change);
249 cmd.cmd.pg.mclk_change.cmd_type =
250 PMU_PG_CMD_ID_PG_PARAM;
251 cmd.cmd.pg.mclk_change.cmd_id =
252 PMU_PG_PARAM_CMD_MCLK_CHANGE;
253 cmd.cmd.pg.mclk_change.data = payload;
254
255 gp106_dbg_pmu("cmd post MS PMU_PG_PARAM_CMD_MCLK_CHANGE");
256 status = gk20a_pmu_cmd_post(g, &cmd, NULL, NULL,
257 PMU_COMMAND_QUEUE_HPQ,
258 nvgpu_pmu_handle_param_lpwr_msg, &ack_status, &seq, ~0);
259
260 pmu_wait_message_cond(&g->pmu, gk20a_get_gr_idle_timeout(g),
261 &ack_status, 1);
262 if (ack_status == 0) {
263 status = -EINVAL;
264 gk20a_err(dev_from_gk20a(g), "MCLK-CHANGE ACK failed");
265 }
266 }
267
268 return status;
269}
270
271u32 nvgpu_lpwr_post_init(struct gk20a *g)
272{
273 struct pmu_cmd cmd;
274 u32 seq;
275 u32 status = 0;
276 u32 ack_status = 0;
277
278 memset(&cmd, 0, sizeof(struct pmu_cmd));
279 cmd.hdr.unit_id = PMU_UNIT_PG;
280 cmd.hdr.size = PMU_CMD_HDR_SIZE +
281 sizeof(struct pmu_pg_cmd_post_init_param);
282
283 cmd.cmd.pg.post_init.cmd_type =
284 PMU_PG_CMD_ID_PG_PARAM;
285 cmd.cmd.pg.post_init.cmd_id =
286 PMU_PG_PARAM_CMD_POST_INIT;
287
288 gp106_dbg_pmu("cmd post post-init PMU_PG_PARAM_CMD_POST_INIT");
289 status = gk20a_pmu_cmd_post(g, &cmd, NULL, NULL,
290 PMU_COMMAND_QUEUE_LPQ,
291 nvgpu_pmu_handle_param_lpwr_msg, &ack_status, &seq, ~0);
292
293 pmu_wait_message_cond(&g->pmu, gk20a_get_gr_idle_timeout(g),
294 &ack_status, 1);
295 if (ack_status == 0) {
296 status = -EINVAL;
297 gk20a_err(dev_from_gk20a(g), "post-init ack failed");
298 }
299
300 return status;
301}
302
303u32 nvgpu_lpwr_is_mscg_supported(struct gk20a *g, u32 pstate_num)
304{
305 struct nvgpu_lpwr_bios_ms_data *pms_data =
306 &g->perf_pmu.lpwr.lwpr_bios_data.ms;
307 struct nvgpu_lpwr_bios_idx_data *pidx_data =
308 &g->perf_pmu.lpwr.lwpr_bios_data.idx;
309 struct pstate *pstate = pstate_find(g, pstate_num);
310 u32 ms_idx;
311
312 gk20a_dbg_fn("");
313
314 if (!pstate)
315 return 0;
316
317 ms_idx = pidx_data->entry[pstate->lpwr_entry_idx].ms_idx;
318 if (pms_data->entry[ms_idx].ms_enabled)
319 return 1;
320 else
321 return 0;
322}
323
324u32 nvgpu_lpwr_is_rppg_supported(struct gk20a *g, u32 pstate_num)
325{
326 struct nvgpu_lpwr_bios_gr_data *pgr_data =
327 &g->perf_pmu.lpwr.lwpr_bios_data.gr;
328 struct nvgpu_lpwr_bios_idx_data *pidx_data =
329 &g->perf_pmu.lpwr.lwpr_bios_data.idx;
330 struct pstate *pstate = pstate_find(g, pstate_num);
331 u32 idx;
332
333 gk20a_dbg_fn("");
334
335 if (!pstate)
336 return 0;
337
338 idx = pidx_data->entry[pstate->lpwr_entry_idx].gr_idx;
339 if (pgr_data->entry[idx].gr_enabled)
340 return 1;
341 else
342 return 0;
343}
344
345
346int nvgpu_lpwr_enable_pg(struct gk20a *g, bool pstate_lock)
347{
348 struct pmu_gk20a *pmu = &g->pmu;
349 u32 status = 0;
350 u32 is_mscg_supported = 0;
351 u32 is_rppg_supported = 0;
352 u32 present_pstate = 0;
353
354 gk20a_dbg_fn("");
355
356 if (pstate_lock)
357 nvgpu_clk_arb_pstate_change_lock(g, true);
358 mutex_lock(&pmu->pg_mutex);
359
360 present_pstate = nvgpu_clk_arb_get_current_pstate(g);
361
362 is_mscg_supported = nvgpu_lpwr_is_mscg_supported(g,
363 present_pstate);
364 if (is_mscg_supported && g->mscg_enabled) {
365 if (!pmu->mscg_stat)
366 pmu->mscg_stat = PMU_MSCG_ENABLED;
367 }
368
369 is_rppg_supported = nvgpu_lpwr_is_rppg_supported(g,
370 present_pstate);
371 if (is_rppg_supported) {
372 if (support_gk20a_pmu(g->dev) && g->elpg_enabled)
373 status = gk20a_pmu_enable_elpg(g);
374 }
375
376 mutex_unlock(&pmu->pg_mutex);
377 if (pstate_lock)
378 nvgpu_clk_arb_pstate_change_lock(g, false);
379
380 return status;
381}
382
383int nvgpu_lpwr_disable_pg(struct gk20a *g, bool pstate_lock)
384{
385 struct pmu_gk20a *pmu = &g->pmu;
386 int status = 0;
387 u32 is_mscg_supported = 0;
388 u32 is_rppg_supported = 0;
389 u32 present_pstate = 0;
390
391 gk20a_dbg_fn("");
392
393 if (pstate_lock)
394 nvgpu_clk_arb_pstate_change_lock(g, true);
395 mutex_lock(&pmu->pg_mutex);
396
397 present_pstate = nvgpu_clk_arb_get_current_pstate(g);
398
399 is_rppg_supported = nvgpu_lpwr_is_rppg_supported(g,
400 present_pstate);
401 if (is_rppg_supported) {
402 if (support_gk20a_pmu(g->dev) && g->elpg_enabled) {
403 status = gk20a_pmu_disable_elpg(g);
404 if (status)
405 goto exit_unlock;
406 }
407 }
408
409 is_mscg_supported = nvgpu_lpwr_is_mscg_supported(g,
410 present_pstate);
411 if (is_mscg_supported && g->mscg_enabled) {
412 if (pmu->mscg_stat)
413 pmu->mscg_stat = PMU_MSCG_DISABLED;
414 }
415
416exit_unlock:
417 mutex_unlock(&pmu->pg_mutex);
418 if (pstate_lock)
419 nvgpu_clk_arb_pstate_change_lock(g, false);
420
421 gk20a_dbg_fn("done");
422 return status;
423}
diff --git a/drivers/gpu/nvgpu/lpwr/lpwr.h b/drivers/gpu/nvgpu/lpwr/lpwr.h
new file mode 100644
index 00000000..6b3259df
--- /dev/null
+++ b/drivers/gpu/nvgpu/lpwr/lpwr.h
@@ -0,0 +1,92 @@
1/*
2 * Copyright (c) 2016, 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#ifndef _MSCG_H_
14#define _MSCG_H_
15
16#define MAX_SWASR_MCLK_FREQ_WITHOUT_WR_TRAINING_MAXWELL_MHZ 540
17
18#define NV_PMU_PG_PARAM_MCLK_CHANGE_MS_SWASR_ENABLED BIT(0x1)
19#define NV_PMU_PG_PARAM_MCLK_CHANGE_GDDR5_WR_TRAINING_ENABLED BIT(0x3)
20
21#define LPWR_ENTRY_COUNT_MAX 0x06
22
23#define LPWR_VBIOS_IDX_ENTRY_COUNT_MAX (LPWR_ENTRY_COUNT_MAX)
24
25#define LPWR_VBIOS_IDX_ENTRY_RSVD \
26 (LPWR_VBIOS_IDX_ENTRY_COUNT_MAX - 1)
27
28#define LPWR_VBIOS_BASE_SAMPLING_PERIOD_DEFAULT (500)
29
30struct nvgpu_lpwr_bios_idx_entry {
31 u8 pcie_idx;
32 u8 gr_idx;
33 u8 ms_idx;
34 u8 di_idx;
35 u8 gc6_idx;
36};
37
38struct nvgpu_lpwr_bios_idx_data {
39 u16 base_sampling_period;
40 struct nvgpu_lpwr_bios_idx_entry entry[LPWR_VBIOS_IDX_ENTRY_COUNT_MAX];
41};
42
43#define LPWR_VBIOS_MS_ENTRY_COUNT_MAX (LPWR_ENTRY_COUNT_MAX)
44
45struct nvgpu_lpwr_bios_ms_entry {
46 bool ms_enabled;
47 u32 feature_mask;
48 u32 asr_efficiency_thresholdl;
49 u16 dynamic_current_logic;
50 u16 dynamic_current_sram;
51};
52
53struct nvgpu_lpwr_bios_ms_data {
54 u8 default_entry_idx;
55 u32 idle_threshold_us;
56 struct nvgpu_lpwr_bios_ms_entry entry[LPWR_VBIOS_MS_ENTRY_COUNT_MAX];
57};
58
59#define LPWR_VBIOS_GR_ENTRY_COUNT_MAX (LPWR_ENTRY_COUNT_MAX)
60
61struct nvgpu_lpwr_bios_gr_entry {
62 bool gr_enabled;
63 u32 feature_mask;
64};
65
66struct nvgpu_lpwr_bios_gr_data {
67 u8 default_entry_idx;
68 u32 idle_threshold_us;
69 u8 adaptive_gr_multiplier;
70 struct nvgpu_lpwr_bios_gr_entry entry[LPWR_VBIOS_GR_ENTRY_COUNT_MAX];
71};
72
73struct nvgpu_lpwr_bios_data {
74 struct nvgpu_lpwr_bios_idx_data idx;
75 struct nvgpu_lpwr_bios_ms_data ms;
76 struct nvgpu_lpwr_bios_gr_data gr;
77};
78
79struct obj_lwpr {
80 struct nvgpu_lpwr_bios_data lwpr_bios_data;
81 u32 mclk_change_cache;
82};
83
84u32 nvgpu_lpwr_pg_setup(struct gk20a *g);
85int nvgpu_lwpr_mclk_change(struct gk20a *g, u32 pstate);
86int nvgpu_lpwr_enable_pg(struct gk20a *g, bool pstate_lock);
87int nvgpu_lpwr_disable_pg(struct gk20a *g, bool pstate_lock);
88u32 nvgpu_lpwr_is_mscg_supported(struct gk20a *g, u32 pstate_num);
89u32 nvgpu_lpwr_is_rppg_supported(struct gk20a *g, u32 pstate_num);
90u32 nvgpu_lpwr_post_init(struct gk20a *g);
91
92#endif
diff --git a/drivers/gpu/nvgpu/lpwr/rppg.c b/drivers/gpu/nvgpu/lpwr/rppg.c
new file mode 100644
index 00000000..40e857ee
--- /dev/null
+++ b/drivers/gpu/nvgpu/lpwr/rppg.c
@@ -0,0 +1,158 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "gk20a/pmu_gk20a.h"
16#include "gp106/pmu_gp106.h"
17#include "gk20a/pmu_api.h"
18#include "gm206/bios_gm206.h"
19#include "pstate/pstate.h"
20#include "include/bios.h"
21#include "pmuif/gpmuif_pg_rppg.h"
22
23static void pmu_handle_rppg_init_msg(struct gk20a *g, struct pmu_msg *msg,
24 void *param, u32 handle, u32 status)
25{
26
27 u8 ctrlId = NV_PMU_RPPG_CTRL_ID_MAX;
28 u32 *success = param;
29
30 if (status == 0) {
31 switch (msg->msg.pg.rppg_msg.cmn.msg_id) {
32 case NV_PMU_RPPG_MSG_ID_INIT_CTRL_ACK:
33 ctrlId = msg->msg.pg.rppg_msg.init_ctrl_ack.ctrl_id;
34 *success = 1;
35 gp106_dbg_pmu("RPPG is acknowledged from PMU %x",
36 msg->msg.pg.msg_type);
37 break;
38 }
39 }
40
41 gp106_dbg_pmu("RPPG is acknowledged from PMU %x",
42 msg->msg.pg.msg_type);
43}
44
45static u32 rppg_send_cmd(struct gk20a *g, struct nv_pmu_rppg_cmd *prppg_cmd)
46{
47 struct pmu_cmd cmd;
48 u32 seq;
49 u32 status = 0;
50 u32 success = 0;
51
52 memset(&cmd, 0, sizeof(struct pmu_cmd));
53 cmd.hdr.unit_id = PMU_UNIT_PG;
54 cmd.hdr.size = PMU_CMD_HDR_SIZE +
55 sizeof(struct nv_pmu_rppg_cmd);
56
57 cmd.cmd.pg.rppg_cmd.cmn.cmd_type = PMU_PMU_PG_CMD_ID_RPPG;
58 cmd.cmd.pg.rppg_cmd.cmn.cmd_id = prppg_cmd->cmn.cmd_id;
59
60 switch (prppg_cmd->cmn.cmd_id) {
61 case NV_PMU_RPPG_CMD_ID_INIT:
62 break;
63 case NV_PMU_RPPG_CMD_ID_INIT_CTRL:
64 cmd.cmd.pg.rppg_cmd.init_ctrl.ctrl_id =
65 prppg_cmd->init_ctrl.ctrl_id;
66 cmd.cmd.pg.rppg_cmd.init_ctrl.domain_id =
67 prppg_cmd->init_ctrl.domain_id;
68 break;
69 case NV_PMU_RPPG_CMD_ID_STATS_RESET:
70 cmd.cmd.pg.rppg_cmd.stats_reset.ctrl_id =
71 prppg_cmd->stats_reset.ctrl_id;
72 break;
73 default:
74 gk20a_err(dev_from_gk20a(g), "Inivalid RPPG command %d",
75 prppg_cmd->cmn.cmd_id);
76 return -1;
77 }
78
79 status = gk20a_pmu_cmd_post(g, &cmd, NULL, NULL, PMU_COMMAND_QUEUE_HPQ,
80 pmu_handle_rppg_init_msg, &success, &seq, ~0);
81 if (status) {
82 gk20a_err(dev_from_gk20a(g), "Unable to submit parameter command %d",
83 prppg_cmd->cmn.cmd_id);
84 goto exit;
85 }
86
87 if (prppg_cmd->cmn.cmd_id == NV_PMU_RPPG_CMD_ID_INIT_CTRL) {
88 pmu_wait_message_cond(&g->pmu, gk20a_get_gr_idle_timeout(g),
89 &success, 1);
90 if (success == 0) {
91 status = -EINVAL;
92 gk20a_err(dev_from_gk20a(g), "Ack for the parameter command %x",
93 prppg_cmd->cmn.cmd_id);
94 }
95 }
96
97exit:
98 return status;
99}
100
101static u32 rppg_init(struct gk20a *g)
102{
103 struct nv_pmu_rppg_cmd rppg_cmd;
104
105 rppg_cmd.init.cmd_id = NV_PMU_RPPG_CMD_ID_INIT;
106
107 return rppg_send_cmd(g, &rppg_cmd);
108}
109
110static u32 rppg_ctrl_init(struct gk20a *g, u8 ctrl_id)
111{
112 struct nv_pmu_rppg_cmd rppg_cmd;
113
114 rppg_cmd.init_ctrl.cmd_id = NV_PMU_RPPG_CMD_ID_INIT_CTRL;
115 rppg_cmd.init_ctrl.ctrl_id = ctrl_id;
116
117 switch (ctrl_id) {
118 case NV_PMU_RPPG_CTRL_ID_GR:
119 case NV_PMU_RPPG_CTRL_ID_MS:
120 rppg_cmd.init_ctrl.domain_id = NV_PMU_RPPG_DOMAIN_ID_GFX;
121 break;
122 }
123
124 return rppg_send_cmd(g, &rppg_cmd);
125}
126
127u32 init_rppg(struct gk20a *g)
128{
129 u32 status;
130
131 status = rppg_init(g);
132 if (status != 0) {
133 gk20a_err(dev_from_gk20a(g),
134 "Failed to initialize RPPG in PMU: 0x%08x", status);
135 return status;
136 }
137
138
139 status = rppg_ctrl_init(g, NV_PMU_RPPG_CTRL_ID_GR);
140 if (status != 0) {
141 gk20a_err(dev_from_gk20a(g),
142 "Failed to initialize RPPG_CTRL: GR in PMU: 0x%08x",
143 status);
144 return status;
145 }
146
147 status = rppg_ctrl_init(g, NV_PMU_RPPG_CTRL_ID_MS);
148 if (status != 0) {
149 gk20a_err(dev_from_gk20a(g),
150 "Failed to initialize RPPG_CTRL: MS in PMU: 0x%08x",
151 status);
152 return status;
153 }
154
155 return status;
156}
157
158
diff --git a/drivers/gpu/nvgpu/lpwr/rppg.h b/drivers/gpu/nvgpu/lpwr/rppg.h
new file mode 100644
index 00000000..8dc8d36c
--- /dev/null
+++ b/drivers/gpu/nvgpu/lpwr/rppg.h
@@ -0,0 +1,17 @@
1/*
2 * Copyright (c) 2016, 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#ifndef _RPPG_H_
14#define _RPPG_H_
15
16u32 init_rppg(struct gk20a *g);
17#endif
diff --git a/drivers/gpu/nvgpu/nvgpu_gpuid_t18x.h b/drivers/gpu/nvgpu/nvgpu_gpuid_t18x.h
new file mode 100644
index 00000000..84da4b96
--- /dev/null
+++ b/drivers/gpu/nvgpu/nvgpu_gpuid_t18x.h
@@ -0,0 +1,45 @@
1/*
2 * NVIDIA GPU ID functions, definitions.
3 *
4 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _NVGPU_GPUID_T18X_H_
16#define _NVGPU_GPUID_T18X_H_
17
18#define NVGPU_GPUID_GP10B \
19 GK20A_GPUID(NVGPU_GPU_ARCH_GP100, NVGPU_GPU_IMPL_GP10B)
20#define NVGPU_GPUID_GP104 \
21 GK20A_GPUID(NVGPU_GPU_ARCH_GP100, NVGPU_GPU_IMPL_GP104)
22#define NVGPU_GPUID_GP106 \
23 GK20A_GPUID(NVGPU_GPU_ARCH_GP100, NVGPU_GPU_IMPL_GP106)
24
25#define NVGPU_COMPAT_TEGRA_GP10B "nvidia,tegra186-gp10b"
26#define NVGPU_COMPAT_GENERIC_GP10B "nvidia,generic-gp10b"
27
28#define TEGRA_18x_GPUID NVGPU_GPUID_GP10B
29#define TEGRA_18x_GPUID_HAL gp10b_init_hal
30#define TEGRA_18x_GPU_COMPAT_TEGRA NVGPU_COMPAT_TEGRA_GP10B
31#define TEGRA_18x_GPU_COMPAT_GENERIC NVGPU_COMPAT_GENERIC_GP10B
32#define TEGRA_18x_GPUID2 NVGPU_GPUID_GP104
33#define TEGRA_18x_GPUID2_HAL gp106_init_hal
34#define TEGRA_18x_GPUID3 NVGPU_GPUID_GP106
35#define TEGRA_18x_GPUID3_HAL gp106_init_hal
36struct gpu_ops;
37extern int gp10b_init_hal(struct gk20a *);
38extern int gp106_init_hal(struct gk20a *);
39extern struct gk20a_platform t18x_gpu_tegra_platform;
40
41#ifdef CONFIG_TEGRA_GR_VIRTUALIZATION
42#define TEGRA_18x_GPUID_VGPU_HAL vgpu_gp10b_init_hal
43extern int vgpu_gp10b_init_hal(struct gk20a *);
44#endif
45#endif
diff --git a/drivers/gpu/nvgpu/perf/perf.c b/drivers/gpu/nvgpu/perf/perf.c
new file mode 100644
index 00000000..41ebb315
--- /dev/null
+++ b/drivers/gpu/nvgpu/perf/perf.c
@@ -0,0 +1,118 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "perf.h"
16#include "pmuif/gpmuifperf.h"
17#include "pmuif/gpmuifperfvfe.h"
18#include "gk20a/pmu_gk20a.h"
19#include "clk/clk_arb.h"
20
21struct perfrpc_pmucmdhandler_params {
22 struct nv_pmu_perf_rpc *prpccall;
23 u32 success;
24};
25
26static void perfrpc_pmucmdhandler(struct gk20a *g, struct pmu_msg *msg,
27 void *param, u32 handle, u32 status)
28{
29 struct perfrpc_pmucmdhandler_params *phandlerparams =
30 (struct perfrpc_pmucmdhandler_params *)param;
31
32 gk20a_dbg_info("");
33
34 if (msg->msg.perf.msg_type != NV_PMU_PERF_MSG_ID_RPC) {
35 gk20a_err(dev_from_gk20a(g),
36 "unsupported msg for VFE LOAD RPC %x",
37 msg->msg.perf.msg_type);
38 return;
39 }
40
41 if (phandlerparams->prpccall->b_supported)
42 phandlerparams->success = 1;
43}
44
45static int pmu_handle_perf_event(struct gk20a *g, void *pmu_msg)
46{
47 struct nv_pmu_perf_msg *msg = (struct nv_pmu_perf_msg *)pmu_msg;
48
49 gk20a_dbg_fn("");
50 switch (msg->msg_type) {
51 case NV_PMU_PERF_MSG_ID_VFE_CALLBACK:
52 nvgpu_clk_arb_schedule_vf_table_update(g);
53 break;
54 default:
55 WARN_ON(1);
56 break;
57 }
58 return 0;
59}
60
61u32 perf_pmu_vfe_load(struct gk20a *g)
62{
63 struct pmu_cmd cmd;
64 struct pmu_msg msg;
65 struct pmu_payload payload = { {0} };
66 u32 status;
67 u32 seqdesc;
68 struct nv_pmu_perf_rpc rpccall = {0};
69 struct perfrpc_pmucmdhandler_params handler = {0};
70
71 /*register call back for future VFE updates*/
72 g->ops.perf.handle_pmu_perf_event = pmu_handle_perf_event;
73
74 rpccall.function = NV_PMU_PERF_RPC_ID_VFE_LOAD;
75 rpccall.params.vfe_load.b_load = true;
76 cmd.hdr.unit_id = PMU_UNIT_PERF;
77 cmd.hdr.size = (u32)sizeof(struct nv_pmu_perf_cmd) +
78 (u32)sizeof(struct pmu_hdr);
79
80 cmd.cmd.perf.cmd_type = NV_PMU_PERF_CMD_ID_RPC;
81 msg.hdr.size = sizeof(struct pmu_msg);
82
83 payload.in.buf = (u8 *)&rpccall;
84 payload.in.size = (u32)sizeof(struct nv_pmu_perf_rpc);
85 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
86 payload.in.offset = NV_PMU_PERF_CMD_RPC_ALLOC_OFFSET;
87
88 payload.out.buf = (u8 *)&rpccall;
89 payload.out.size = (u32)sizeof(struct nv_pmu_perf_rpc);
90 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
91 payload.out.offset = NV_PMU_PERF_MSG_RPC_ALLOC_OFFSET;
92
93 handler.prpccall = &rpccall;
94 handler.success = 0;
95
96 status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload,
97 PMU_COMMAND_QUEUE_LPQ,
98 perfrpc_pmucmdhandler, (void *)&handler,
99 &seqdesc, ~0);
100
101 if (status) {
102 gk20a_err(dev_from_gk20a(g),
103 "unable to post perf RPC cmd %x",
104 cmd.cmd.perf.cmd_type);
105 goto done;
106 }
107
108 pmu_wait_message_cond(&g->pmu,
109 gk20a_get_gr_idle_timeout(g),
110 &handler.success, 1);
111
112 if (handler.success == 0) {
113 status = -EINVAL;
114 gk20a_err(dev_from_gk20a(g), "rpc call to load VFE failed");
115 }
116done:
117 return status;
118}
diff --git a/drivers/gpu/nvgpu/perf/perf.h b/drivers/gpu/nvgpu/perf/perf.h
new file mode 100644
index 00000000..a3213f7a
--- /dev/null
+++ b/drivers/gpu/nvgpu/perf/perf.h
@@ -0,0 +1,66 @@
1/*
2 * Copyright (c) 2016, 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#ifndef _PERF_H_
14#define _PERF_H_
15
16#include "vfe_equ.h"
17#include "vfe_var.h"
18#include "pstate/pstate.h"
19#include "gk20a/gk20a.h"
20#include "volt/volt.h"
21#include "lpwr/lpwr.h"
22
23#define CTRL_PERF_VFE_VAR_TYPE_INVALID 0x00
24#define CTRL_PERF_VFE_VAR_TYPE_DERIVED 0x01
25#define CTRL_PERF_VFE_VAR_TYPE_DERIVED_PRODUCT 0x02
26#define CTRL_PERF_VFE_VAR_TYPE_DERIVED_SUM 0x03
27#define CTRL_PERF_VFE_VAR_TYPE_SINGLE 0x04
28#define CTRL_PERF_VFE_VAR_TYPE_SINGLE_FREQUENCY 0x05
29#define CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED 0x06
30#define CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_FUSE 0x07
31#define CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_TEMP 0x08
32#define CTRL_PERF_VFE_VAR_TYPE_SINGLE_VOLTAGE 0x09
33
34#define CTRL_PERF_VFE_VAR_SINGLE_OVERRIDE_TYPE_NONE 0x00
35#define CTRL_PERF_VFE_VAR_SINGLE_OVERRIDE_TYPE_VALUE 0x01
36#define CTRL_PERF_VFE_VAR_SINGLE_OVERRIDE_TYPE_OFFSET 0x02
37#define CTRL_PERF_VFE_VAR_SINGLE_OVERRIDE_TYPE_SCALE 0x03
38
39#define CTRL_PERF_VFE_EQU_TYPE_INVALID 0x00
40#define CTRL_PERF_VFE_EQU_TYPE_COMPARE 0x01
41#define CTRL_PERF_VFE_EQU_TYPE_MINMAX 0x02
42#define CTRL_PERF_VFE_EQU_TYPE_QUADRATIC 0x03
43
44#define CTRL_PERF_VFE_EQU_OUTPUT_TYPE_UNITLESS 0x00
45#define CTRL_PERF_VFE_EQU_OUTPUT_TYPE_FREQ_MHZ 0x01
46#define CTRL_PERF_VFE_EQU_OUTPUT_TYPE_VOLT_UV 0x02
47#define CTRL_PERF_VFE_EQU_OUTPUT_TYPE_VF_GAIN 0x03
48#define CTRL_PERF_VFE_EQU_OUTPUT_TYPE_VOLT_DELTA_UV 0x04
49
50#define CTRL_PERF_VFE_EQU_QUADRATIC_COEFF_COUNT 0x03
51
52#define CTRL_PERF_VFE_EQU_COMPARE_FUNCTION_EQUAL 0x00
53#define CTRL_PERF_VFE_EQU_COMPARE_FUNCTION_GREATER_EQ 0x01
54#define CTRL_PERF_VFE_EQU_COMPARE_FUNCTION_GREATER 0x02
55
56struct perf_pmupstate {
57 struct vfe_vars vfe_varobjs;
58 struct vfe_equs vfe_equobjs;
59 struct pstates pstatesobjs;
60 struct obj_volt volt;
61 struct obj_lwpr lpwr;
62};
63
64u32 perf_pmu_vfe_load(struct gk20a *g);
65
66#endif
diff --git a/drivers/gpu/nvgpu/perf/vfe_equ.c b/drivers/gpu/nvgpu/perf/vfe_equ.c
new file mode 100644
index 00000000..6630fb21
--- /dev/null
+++ b/drivers/gpu/nvgpu/perf/vfe_equ.c
@@ -0,0 +1,590 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "perf.h"
16#include "vfe_equ.h"
17#include "include/bios.h"
18#include "boardobj/boardobjgrp.h"
19#include "boardobj/boardobjgrp_e255.h"
20#include "pmuif/gpmuifboardobj.h"
21#include "pmuif/gpmuifperf.h"
22#include "pmuif/gpmuifperfvfe.h"
23#include "gm206/bios_gm206.h"
24#include "ctrl/ctrlclk.h"
25#include "ctrl/ctrlvolt.h"
26#include "gk20a/pmu_gk20a.h"
27
28static struct vfe_equ *construct_vfe_equ(struct gk20a *g, void *pargs);
29static u32 devinit_get_vfe_equ_table(struct gk20a *g,
30 struct vfe_equs *pequobjs);
31
32static u32 _vfe_equs_pmudatainit(struct gk20a *g,
33 struct boardobjgrp *pboardobjgrp,
34 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu)
35{
36 u32 status = 0;
37
38 status = boardobjgrp_pmudatainit_e255(g, pboardobjgrp, pboardobjgrppmu);
39 if (status) {
40 gk20a_err(dev_from_gk20a(g),
41 "error updating pmu boardobjgrp for vfe equ 0x%x",
42 status);
43 goto done;
44 }
45
46done:
47 return status;
48}
49
50static u32 _vfe_equs_pmudata_instget(struct gk20a *g,
51 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
52 struct nv_pmu_boardobj **ppboardobjpmudata,
53 u8 idx)
54{
55 struct nv_pmu_perf_vfe_equ_boardobj_grp_set *pgrp_set =
56 (struct nv_pmu_perf_vfe_equ_boardobj_grp_set *)pmuboardobjgrp;
57
58 gk20a_dbg_info("");
59
60 /* check whether pmuboardobjgrp has a valid boardobj in index */
61 if (idx >= CTRL_BOARDOBJGRP_E255_MAX_OBJECTS)
62 return -EINVAL;
63
64 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
65 &pgrp_set->objects[idx].data.board_obj;
66 gk20a_dbg_info(" Done");
67 return 0;
68}
69
70u32 vfe_equ_sw_setup(struct gk20a *g)
71{
72 u32 status;
73 struct boardobjgrp *pboardobjgrp = NULL;
74 struct vfe_equs *pvfeequobjs;
75
76 gk20a_dbg_info("");
77
78 status = boardobjgrpconstruct_e255(&g->perf_pmu.vfe_equobjs.super);
79 if (status) {
80 gk20a_err(dev_from_gk20a(g),
81 "error creating boardobjgrp for clk domain, status - 0x%x",
82 status);
83 goto done;
84 }
85
86 pboardobjgrp = &g->perf_pmu.vfe_equobjs.super.super;
87 pvfeequobjs = &(g->perf_pmu.vfe_equobjs);
88
89 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, PERF, VFE_EQU);
90
91 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
92 perf, PERF, vfe_equ, VFE_EQU);
93 if (status) {
94 gk20a_err(dev_from_gk20a(g),
95 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
96 status);
97 goto done;
98 }
99
100 pboardobjgrp->pmudatainit = _vfe_equs_pmudatainit;
101 pboardobjgrp->pmudatainstget = _vfe_equs_pmudata_instget;
102
103 status = devinit_get_vfe_equ_table(g, pvfeequobjs);
104 if (status)
105 goto done;
106
107done:
108 gk20a_dbg_info(" done status %x", status);
109 return status;
110}
111
112u32 vfe_equ_pmu_setup(struct gk20a *g)
113{
114 u32 status;
115 struct boardobjgrp *pboardobjgrp = NULL;
116
117 gk20a_dbg_info("");
118
119 pboardobjgrp = &g->perf_pmu.vfe_equobjs.super.super;
120
121 if (!pboardobjgrp->bconstructed)
122 return -EINVAL;
123
124 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
125
126 gk20a_dbg_info("Done");
127 return status;
128}
129
130static u32 devinit_get_vfe_equ_table(struct gk20a *g,
131 struct vfe_equs *pvfeequobjs)
132{
133 u32 status = 0;
134 u8 *vfeequs_tbl_ptr = NULL;
135 struct vbios_vfe_3x_header_struct vfeequs_tbl_header = { 0 };
136 struct vbios_vfe_3x_equ_entry_struct equ = { 0 };
137 u8 *vfeequs_tbl_entry_ptr = NULL;
138 u8 *rd_offset_ptr = NULL;
139 u32 index = 0;
140 struct vfe_equ *pequ;
141 u8 equ_type = 0;
142 u32 szfmt;
143 union {
144 struct boardobj board_obj;
145 struct vfe_equ super;
146 struct vfe_equ_compare compare;
147 struct vfe_equ_minmax minmax;
148 struct vfe_equ_quadratic quadratic;
149 } equ_data;
150
151 gk20a_dbg_info("");
152
153 if (g->ops.bios.get_perf_table_ptrs) {
154 vfeequs_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
155 g->bios.perf_token,
156 CONTINUOUS_VIRTUAL_BINNING_TABLE);
157 if (vfeequs_tbl_ptr == NULL) {
158 status = -EINVAL;
159 goto done;
160 }
161 }
162
163 memcpy(&vfeequs_tbl_header, vfeequs_tbl_ptr,
164 VBIOS_CLOCKS_TABLE_1X_HEADER_SIZE_07);
165 if (vfeequs_tbl_header.header_size != VBIOS_CLOCKS_TABLE_1X_HEADER_SIZE_07) {
166 status = -EINVAL;
167 goto done;
168 }
169
170 if (vfeequs_tbl_header.vfe_equ_entry_size ==
171 VBIOS_VFE_3X_EQU_ENTRY_SIZE_17)
172 szfmt = VBIOS_VFE_3X_EQU_ENTRY_SIZE_17;
173 else if (vfeequs_tbl_header.vfe_equ_entry_size ==
174 VBIOS_VFE_3X_EQU_ENTRY_SIZE_18)
175 szfmt = VBIOS_VFE_3X_EQU_ENTRY_SIZE_18;
176 else {
177 status = -EINVAL;
178 goto done;
179 }
180
181 vfeequs_tbl_entry_ptr = vfeequs_tbl_ptr +
182 vfeequs_tbl_header.header_size +
183 (vfeequs_tbl_header.vfe_var_entry_count *
184 vfeequs_tbl_header.vfe_var_entry_size);
185
186 for (index = 0;
187 index < vfeequs_tbl_header.vfe_equ_entry_count;
188 index++) {
189 memset(&equ, 0, sizeof(struct vbios_vfe_3x_equ_entry_struct));
190
191 rd_offset_ptr = vfeequs_tbl_entry_ptr +
192 (index * vfeequs_tbl_header.vfe_equ_entry_size);
193
194 memcpy(&equ, rd_offset_ptr, szfmt);
195
196 equ_data.super.var_idx = (u8)equ.var_idx;
197 equ_data.super.equ_idx_next =
198 (equ.equ_idx_next == VBIOS_VFE_3X_EQU_ENTRY_IDX_INVALID) ?
199 CTRL_BOARDOBJ_IDX_INVALID : (u8)equ.equ_idx_next;
200 equ_data.super.out_range_min = equ.out_range_min;
201 equ_data.super.out_range_max = equ.out_range_max;
202
203 switch (BIOS_GET_FIELD(equ.param3, VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE)) {
204 case VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_UNITLESS:
205 equ_data.super.output_type =
206 CTRL_PERF_VFE_EQU_OUTPUT_TYPE_UNITLESS;
207 break;
208
209 case VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_FREQ_MHZ:
210 equ_data.super.output_type =
211 CTRL_PERF_VFE_EQU_OUTPUT_TYPE_FREQ_MHZ;
212 break;
213
214 case VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_VOLT_UV:
215 equ_data.super.output_type =
216 CTRL_PERF_VFE_EQU_OUTPUT_TYPE_VOLT_UV;
217 break;
218
219 case VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_VF_GAIN:
220 equ_data.super.output_type =
221 CTRL_PERF_VFE_EQU_OUTPUT_TYPE_VF_GAIN;
222 break;
223
224 case VBIOS_VFE_3X_EQU_ENTRY_PAR3_OUTPUT_TYPE_VOLT_DELTA_UV:
225 equ_data.super.output_type =
226 CTRL_PERF_VFE_EQU_OUTPUT_TYPE_VOLT_DELTA_UV;
227 break;
228
229 default:
230 gk20a_err(dev_from_gk20a(g),
231 "unrecognized output id @vfeequ index %d",
232 index);
233 goto done;
234 }
235
236 switch ((u8)equ.type) {
237 case VBIOS_VFE_3X_EQU_ENTRY_TYPE_DISABLED:
238 case VBIOS_VFE_3X_EQU_ENTRY_TYPE_QUADRATIC_FXP:
239 case VBIOS_VFE_3X_EQU_ENTRY_TYPE_MINMAX_FXP:
240 continue;
241 break;
242
243 case VBIOS_VFE_3X_EQU_ENTRY_TYPE_QUADRATIC:
244 equ_type = CTRL_PERF_VFE_EQU_TYPE_QUADRATIC;
245 equ_data.quadratic.coeffs[0] = equ.param0;
246 equ_data.quadratic.coeffs[1] = equ.param1;
247 equ_data.quadratic.coeffs[2] = equ.param2;
248 break;
249
250 case VBIOS_VFE_3X_EQU_ENTRY_TYPE_MINMAX:
251 equ_type = CTRL_PERF_VFE_EQU_TYPE_MINMAX;
252 equ_data.minmax.b_max = BIOS_GET_FIELD(equ.param0,
253 VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_CRIT) &&
254 VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_CRIT_MAX;
255 equ_data.minmax.equ_idx0 = (u8)BIOS_GET_FIELD(
256 equ.param0,
257 VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_VFE_EQU_IDX_0);
258 equ_data.minmax.equ_idx1 = (u8)BIOS_GET_FIELD(
259 equ.param0,
260 VBIOS_VFE_3X_EQU_ENTRY_PAR0_MINMAX_VFE_EQU_IDX_1);
261 break;
262
263 case VBIOS_VFE_3X_EQU_ENTRY_TYPE_COMPARE:
264 {
265 u8 cmp_func = (u8)BIOS_GET_FIELD(
266 equ.param1,
267 VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_FUNCTION);
268 equ_type = CTRL_PERF_VFE_EQU_TYPE_COMPARE;
269
270 switch (cmp_func) {
271 case VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_FUNCTION_EQUAL:
272 equ_data.compare.func_id =
273 CTRL_PERF_VFE_EQU_COMPARE_FUNCTION_EQUAL;
274 break;
275
276 case VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_FUNCTION_GREATER_EQ:
277 equ_data.compare.func_id =
278 CTRL_PERF_VFE_EQU_COMPARE_FUNCTION_GREATER_EQ;
279 break;
280 case VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_FUNCTION_GREATER:
281 equ_data.compare.func_id =
282 CTRL_PERF_VFE_EQU_COMPARE_FUNCTION_GREATER;
283 break;
284 default:
285 gk20a_err(dev_from_gk20a(g),
286 "invalid vfe compare index %x type %x ",
287 index, cmp_func);
288 status = -EINVAL;
289 goto done;
290 }
291 equ_data.compare.equ_idx_true = (u8)BIOS_GET_FIELD(
292 equ.param1,
293 VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_VFE_EQU_IDX_TRUE);
294 equ_data.compare.equ_idx_false = (u8)BIOS_GET_FIELD(
295 equ.param1,
296 VBIOS_VFE_3X_EQU_ENTRY_PAR1_COMPARE_VFE_EQU_IDX_FALSE);
297 equ_data.compare.criteria = equ.param0;
298 break;
299 }
300 default:
301 status = -EINVAL;
302 gk20a_err(dev_from_gk20a(g),
303 "Invalid equ[%d].type = 0x%x.",
304 index, (u8)equ.type);
305 goto done;
306 }
307
308 equ_data.board_obj.type = equ_type;
309 pequ = construct_vfe_equ(g, (void *)&equ_data);
310
311 if (pequ == NULL) {
312 gk20a_err(dev_from_gk20a(g),
313 "error constructing vfe_equ boardobj %d", index);
314 status = -EINVAL;
315 goto done;
316 }
317
318 status = boardobjgrp_objinsert(&pvfeequobjs->super.super,
319 (struct boardobj *)pequ, index);
320 if (status) {
321 gk20a_err(dev_from_gk20a(g),
322 "error adding vfe_equ boardobj %d", index);
323 status = -EINVAL;
324 goto done;
325 }
326 }
327done:
328 gk20a_dbg_info(" done status %x", status);
329 return status;
330}
331
332static u32 _vfe_equ_pmudatainit_super(struct gk20a *g,
333 struct boardobj *board_obj_ptr,
334 struct nv_pmu_boardobj *ppmudata)
335{
336 u32 status = 0;
337 struct vfe_equ *pvfe_equ;
338 struct nv_pmu_vfe_equ *pset;
339
340 gk20a_dbg_info("");
341
342 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
343 if (status != 0)
344 return status;
345
346 pvfe_equ = (struct vfe_equ *)board_obj_ptr;
347
348 pset = (struct nv_pmu_vfe_equ *)
349 ppmudata;
350
351 pset->var_idx = pvfe_equ->var_idx;
352 pset->equ_idx_next = pvfe_equ->equ_idx_next;
353 pset->output_type = pvfe_equ->output_type;
354 pset->out_range_min = pvfe_equ->out_range_min;
355 pset->out_range_max = pvfe_equ->out_range_max;
356
357 return status;
358}
359
360static u32 vfe_equ_construct_super(struct gk20a *g,
361 struct boardobj **ppboardobj,
362 u16 size, void *pargs)
363{
364 struct vfe_equ *pvfeequ;
365 struct vfe_equ *ptmpequ = (struct vfe_equ *)pargs;
366 u32 status = 0;
367
368 status = boardobj_construct_super(g, ppboardobj,
369 size, pargs);
370 if (status)
371 return -EINVAL;
372
373 pvfeequ = (struct vfe_equ *)*ppboardobj;
374
375 pvfeequ->super.pmudatainit =
376 _vfe_equ_pmudatainit_super;
377
378 pvfeequ->var_idx = ptmpequ->var_idx;
379 pvfeequ->equ_idx_next = ptmpequ->equ_idx_next;
380 pvfeequ->output_type = ptmpequ->output_type;
381 pvfeequ->out_range_min = ptmpequ->out_range_min;
382 pvfeequ->out_range_max = ptmpequ->out_range_max;
383
384 return status;
385}
386
387static u32 _vfe_equ_pmudatainit_compare(struct gk20a *g,
388 struct boardobj *board_obj_ptr,
389 struct nv_pmu_boardobj *ppmudata)
390{
391 u32 status = 0;
392 struct vfe_equ_compare *pvfe_equ_compare;
393 struct nv_pmu_vfe_equ_compare *pset;
394
395 gk20a_dbg_info("");
396
397 status = _vfe_equ_pmudatainit_super(g, board_obj_ptr, ppmudata);
398 if (status != 0)
399 return status;
400
401 pvfe_equ_compare = (struct vfe_equ_compare *)board_obj_ptr;
402
403 pset = (struct nv_pmu_vfe_equ_compare *) ppmudata;
404
405 pset->func_id = pvfe_equ_compare->func_id;
406 pset->equ_idx_true = pvfe_equ_compare->equ_idx_true;
407 pset->equ_idx_false = pvfe_equ_compare->equ_idx_false;
408 pset->criteria = pvfe_equ_compare->criteria;
409
410 return status;
411}
412
413
414static u32 vfe_equ_construct_compare(struct gk20a *g,
415 struct boardobj **ppboardobj,
416 u16 size, void *pargs)
417{
418 struct boardobj *ptmpobj = (struct boardobj *)pargs;
419 struct vfe_equ_compare *pvfeequ;
420 struct vfe_equ_compare *ptmpequ =
421 (struct vfe_equ_compare *)pargs;
422 u32 status = 0;
423
424 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_PERF_VFE_EQU_TYPE_COMPARE)
425 return -EINVAL;
426
427 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_EQU_TYPE_COMPARE);
428 status = vfe_equ_construct_super(g, ppboardobj, size, pargs);
429 if (status)
430 return -EINVAL;
431
432 pvfeequ = (struct vfe_equ_compare *)*ppboardobj;
433
434 pvfeequ->super.super.pmudatainit =
435 _vfe_equ_pmudatainit_compare;
436
437 pvfeequ->func_id = ptmpequ->func_id;
438 pvfeequ->equ_idx_true = ptmpequ->equ_idx_true;
439 pvfeequ->equ_idx_false = ptmpequ->equ_idx_false;
440 pvfeequ->criteria = ptmpequ->criteria;
441
442
443 return status;
444}
445
446static u32 _vfe_equ_pmudatainit_minmax(struct gk20a *g,
447 struct boardobj *board_obj_ptr,
448 struct nv_pmu_boardobj *ppmudata)
449{
450 u32 status = 0;
451 struct vfe_equ_minmax *pvfe_equ_minmax;
452 struct nv_pmu_vfe_equ_minmax *pset;
453
454 gk20a_dbg_info("");
455
456 status = _vfe_equ_pmudatainit_super(g, board_obj_ptr, ppmudata);
457 if (status != 0)
458 return status;
459
460 pvfe_equ_minmax = (struct vfe_equ_minmax *)board_obj_ptr;
461
462 pset = (struct nv_pmu_vfe_equ_minmax *)
463 ppmudata;
464
465 pset->b_max = pvfe_equ_minmax->b_max;
466 pset->equ_idx0 = pvfe_equ_minmax->equ_idx0;
467 pset->equ_idx1 = pvfe_equ_minmax->equ_idx1;
468
469 return status;
470}
471
472static u32 vfe_equ_construct_minmax(struct gk20a *g,
473 struct boardobj **ppboardobj,
474 u16 size, void *pargs)
475{
476 struct boardobj *ptmpobj = (struct boardobj *)pargs;
477 struct vfe_equ_minmax *pvfeequ;
478 struct vfe_equ_minmax *ptmpequ =
479 (struct vfe_equ_minmax *)pargs;
480 u32 status = 0;
481
482 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_PERF_VFE_EQU_TYPE_MINMAX)
483 return -EINVAL;
484
485 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_EQU_TYPE_MINMAX);
486 status = vfe_equ_construct_super(g, ppboardobj, size, pargs);
487 if (status)
488 return -EINVAL;
489
490 pvfeequ = (struct vfe_equ_minmax *)*ppboardobj;
491
492 pvfeequ->super.super.pmudatainit =
493 _vfe_equ_pmudatainit_minmax;
494 pvfeequ->b_max = ptmpequ->b_max;
495 pvfeequ->equ_idx0 = ptmpequ->equ_idx0;
496 pvfeequ->equ_idx1 = ptmpequ->equ_idx1;
497
498 return status;
499}
500
501static u32 _vfe_equ_pmudatainit_quadratic(struct gk20a *g,
502 struct boardobj *board_obj_ptr,
503 struct nv_pmu_boardobj *ppmudata)
504{
505 u32 status = 0;
506 struct vfe_equ_quadratic *pvfe_equ_quadratic;
507 struct nv_pmu_vfe_equ_quadratic *pset;
508 u32 i;
509
510 gk20a_dbg_info("");
511
512 status = _vfe_equ_pmudatainit_super(g, board_obj_ptr, ppmudata);
513 if (status != 0)
514 return status;
515
516 pvfe_equ_quadratic = (struct vfe_equ_quadratic *)board_obj_ptr;
517
518 pset = (struct nv_pmu_vfe_equ_quadratic *) ppmudata;
519
520 for (i = 0; i < CTRL_PERF_VFE_EQU_QUADRATIC_COEFF_COUNT; i++)
521 pset->coeffs[i] = pvfe_equ_quadratic->coeffs[i];
522
523 return status;
524}
525
526static u32 vfe_equ_construct_quadratic(struct gk20a *g,
527 struct boardobj **ppboardobj,
528 u16 size, void *pargs)
529{
530 struct boardobj *ptmpobj = (struct boardobj *)pargs;
531 struct vfe_equ_quadratic *pvfeequ;
532 struct vfe_equ_quadratic *ptmpequ =
533 (struct vfe_equ_quadratic *)pargs;
534 u32 status = 0;
535 u32 i;
536
537 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_PERF_VFE_EQU_TYPE_QUADRATIC)
538 return -EINVAL;
539
540 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_EQU_TYPE_QUADRATIC);
541 status = vfe_equ_construct_super(g, ppboardobj, size, pargs);
542 if (status)
543 return -EINVAL;
544
545 pvfeequ = (struct vfe_equ_quadratic *)*ppboardobj;
546
547 pvfeequ->super.super.pmudatainit =
548 _vfe_equ_pmudatainit_quadratic;
549
550 for (i = 0; i < CTRL_PERF_VFE_EQU_QUADRATIC_COEFF_COUNT; i++)
551 pvfeequ->coeffs[i] = ptmpequ->coeffs[i];
552
553 return status;
554}
555
556static struct vfe_equ *construct_vfe_equ(struct gk20a *g, void *pargs)
557{
558 struct boardobj *board_obj_ptr = NULL;
559 u32 status;
560
561 gk20a_dbg_info("");
562
563 switch (BOARDOBJ_GET_TYPE(pargs)) {
564 case CTRL_PERF_VFE_EQU_TYPE_COMPARE:
565 status = vfe_equ_construct_compare(g, &board_obj_ptr,
566 sizeof(struct vfe_equ_compare), pargs);
567 break;
568
569 case CTRL_PERF_VFE_EQU_TYPE_MINMAX:
570 status = vfe_equ_construct_minmax(g, &board_obj_ptr,
571 sizeof(struct vfe_equ_minmax), pargs);
572 break;
573
574 case CTRL_PERF_VFE_EQU_TYPE_QUADRATIC:
575 status = vfe_equ_construct_quadratic(g, &board_obj_ptr,
576 sizeof(struct vfe_equ_quadratic), pargs);
577 break;
578
579 default:
580 return NULL;
581
582 }
583
584 if (status)
585 return NULL;
586
587 gk20a_dbg_info(" Done");
588
589 return (struct vfe_equ *)board_obj_ptr;
590}
diff --git a/drivers/gpu/nvgpu/perf/vfe_equ.h b/drivers/gpu/nvgpu/perf/vfe_equ.h
new file mode 100644
index 00000000..8aaddccd
--- /dev/null
+++ b/drivers/gpu/nvgpu/perf/vfe_equ.h
@@ -0,0 +1,76 @@
1/*
2 * general perf structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _VFE_EQU_H_
16#define _VFE_EQU_H_
17
18#include "boardobj/boardobjgrp.h"
19#include "perf/vfe_var.h"
20#include "pmuif/gpmuifperf.h"
21#include "pmuif/gpmuifperfvfe.h"
22
23u32 vfe_equ_sw_setup(struct gk20a *g);
24u32 vfe_equ_pmu_setup(struct gk20a *g);
25
26#define VFE_EQU_GET(_pperf, _idx) \
27 ((struct vfe_equ *)BOARDOBJGRP_OBJ_GET_BY_IDX( \
28 &((_pperf)->vfe.equs.super.super), (_idx)))
29
30#define VFE_EQU_IDX_IS_VALID(_pperf, _idx) \
31 boardobjgrp_idxisvalid(&((_pperf)->vfe.equs.super.super), (_idx))
32
33#define VFE_EQU_OUTPUT_TYPE_IS_VALID(_pperf, _idx, _outputtype) \
34 (VFE_EQU_IDX_IS_VALID((_pperf), (_idx)) && \
35 ((_outputtype) != CTRL_PERF_VFE_EQU_OUTPUT_TYPE_UNITLESS) && \
36 ((VFE_EQU_GET((_pperf), (_idx))->outputtype == (_outputtype)) || \
37 (VFE_EQU_GET((_pperf), (_idx))->outputtype == \
38 CTRL_PERF_VFE_EQU_OUTPUT_TYPE_UNITLESS)))
39
40struct vfe_equ {
41 struct boardobj super;
42 u8 var_idx;
43 u8 equ_idx_next;
44 u8 output_type;
45 u32 out_range_min;
46 u32 out_range_max;
47
48 bool b_is_dynamic_valid;
49 bool b_is_dynamic;
50};
51
52struct vfe_equs {
53 struct boardobjgrp_e255 super;
54};
55
56struct vfe_equ_compare {
57 struct vfe_equ super;
58 u8 func_id;
59 u8 equ_idx_true;
60 u8 equ_idx_false;
61 u32 criteria;
62};
63
64struct vfe_equ_minmax {
65 struct vfe_equ super;
66 bool b_max;
67 u8 equ_idx0;
68 u8 equ_idx1;
69};
70
71struct vfe_equ_quadratic {
72 struct vfe_equ super;
73 u32 coeffs[CTRL_PERF_VFE_EQU_QUADRATIC_COEFF_COUNT];
74};
75
76#endif
diff --git a/drivers/gpu/nvgpu/perf/vfe_var.c b/drivers/gpu/nvgpu/perf/vfe_var.c
new file mode 100644
index 00000000..4f8dc83b
--- /dev/null
+++ b/drivers/gpu/nvgpu/perf/vfe_var.c
@@ -0,0 +1,1048 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "perf.h"
16#include "vfe_var.h"
17#include "include/bios.h"
18#include "boardobj/boardobjgrp.h"
19#include "boardobj/boardobjgrp_e32.h"
20#include "pmuif/gpmuifboardobj.h"
21#include "pmuif/gpmuifperf.h"
22#include "pmuif/gpmuifperfvfe.h"
23#include "gm206/bios_gm206.h"
24#include "ctrl/ctrlclk.h"
25#include "ctrl/ctrlvolt.h"
26#include "gk20a/pmu_gk20a.h"
27
28static u32 devinit_get_vfe_var_table(struct gk20a *g,
29 struct vfe_vars *pvarobjs);
30static u32 vfe_var_construct_single(struct gk20a *g,
31 struct boardobj **ppboardobj,
32 u16 size, void *pargs);
33
34static u32 _vfe_vars_pmudatainit(struct gk20a *g,
35 struct boardobjgrp *pboardobjgrp,
36 struct nv_pmu_boardobjgrp_super *pboardobjgrppmu)
37{
38 struct nv_pmu_perf_vfe_var_boardobjgrp_set_header *pset =
39 (struct nv_pmu_perf_vfe_var_boardobjgrp_set_header *)
40 pboardobjgrppmu;
41 struct vfe_vars *pvars = (struct vfe_vars *)pboardobjgrp;
42 u32 status = 0;
43
44 status = boardobjgrp_pmudatainit_e32(g, pboardobjgrp, pboardobjgrppmu);
45 if (status) {
46 gk20a_err(dev_from_gk20a(g),
47 "error updating pmu boardobjgrp for vfe var 0x%x",
48 status);
49 goto done;
50 }
51 pset->polling_periodms = pvars->polling_periodms;
52
53done:
54 return status;
55}
56
57static u32 _vfe_vars_pmudata_instget(struct gk20a *g,
58 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
59 struct nv_pmu_boardobj **ppboardobjpmudata,
60 u8 idx)
61{
62 struct nv_pmu_perf_vfe_var_boardobj_grp_set *pgrp_set =
63 (struct nv_pmu_perf_vfe_var_boardobj_grp_set *)
64 pmuboardobjgrp;
65
66 gk20a_dbg_info("");
67
68 /*check whether pmuboardobjgrp has a valid boardobj in index*/
69 if (idx >= CTRL_BOARDOBJGRP_E32_MAX_OBJECTS)
70 return -EINVAL;
71
72 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
73 &pgrp_set->objects[idx].data.board_obj;
74
75 gk20a_dbg_info(" Done");
76 return 0;
77}
78
79static u32 _vfe_vars_pmustatus_instget(struct gk20a *g, void *pboardobjgrppmu,
80 struct nv_pmu_boardobj_query **ppboardobjpmustatus, u8 idx)
81{
82 struct nv_pmu_perf_vfe_var_boardobj_grp_get_status *pgrp_get_status =
83 (struct nv_pmu_perf_vfe_var_boardobj_grp_get_status *)
84 pboardobjgrppmu;
85
86 if (((u32)BIT(idx) &
87 pgrp_get_status->hdr.data.super.obj_mask.super.data[0]) == 0)
88 return -EINVAL;
89
90 *ppboardobjpmustatus = (struct nv_pmu_boardobj_query *)
91 &pgrp_get_status->objects[idx].data.board_obj;
92 return 0;
93}
94
95
96u32 vfe_var_sw_setup(struct gk20a *g)
97{
98 u32 status;
99 struct boardobjgrp *pboardobjgrp = NULL;
100 struct vfe_vars *pvfevarobjs;
101
102 gk20a_dbg_info("");
103
104 status = boardobjgrpconstruct_e32(&g->perf_pmu.vfe_varobjs.super);
105 if (status) {
106 gk20a_err(dev_from_gk20a(g),
107 "error creating boardobjgrp for clk domain, status - 0x%x",
108 status);
109 goto done;
110 }
111
112 pboardobjgrp = &g->perf_pmu.vfe_varobjs.super.super;
113 pvfevarobjs = &g->perf_pmu.vfe_varobjs;
114
115 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, PERF, VFE_VAR);
116
117 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
118 perf, PERF, vfe_var, VFE_VAR);
119 if (status) {
120 gk20a_err(dev_from_gk20a(g),
121 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
122 status);
123 goto done;
124 }
125
126 pboardobjgrp->pmudatainit = _vfe_vars_pmudatainit;
127 pboardobjgrp->pmudatainstget = _vfe_vars_pmudata_instget;
128 pboardobjgrp->pmustatusinstget = _vfe_vars_pmustatus_instget;
129
130 status = devinit_get_vfe_var_table(g, pvfevarobjs);
131 if (status)
132 goto done;
133
134 status = BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g,
135 &g->perf_pmu.vfe_varobjs.super.super,
136 perf, PERF, vfe_var, VFE_VAR);
137 if (status) {
138 gk20a_err(dev_from_gk20a(g),
139 "error constructing PMU_BOARDOBJ_CMD_GRP_GET_STATUS interface - 0x%x",
140 status);
141 goto done;
142 }
143
144done:
145 gk20a_dbg_info(" done status %x", status);
146 return status;
147}
148
149u32 vfe_var_pmu_setup(struct gk20a *g)
150{
151 u32 status;
152 struct boardobjgrp *pboardobjgrp = NULL;
153
154 gk20a_dbg_info("");
155
156 pboardobjgrp = &g->perf_pmu.vfe_varobjs.super.super;
157
158 if (!pboardobjgrp->bconstructed)
159 return -EINVAL;
160
161 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
162
163 gk20a_dbg_info("Done");
164 return status;
165}
166
167u32 dev_init_get_vfield_info(struct gk20a *g,
168 struct vfe_var_single_sensed_fuse *pvfevar)
169{
170 u8 *vfieldtableptr = NULL;
171 u32 vfieldheadersize = VFIELD_HEADER_SIZE;
172 u8 *vfieldregtableptr = NULL;
173 u32 vfieldregheadersize = VFIELD_REG_HEADER_SIZE;
174 u32 i;
175 u32 oldindex = 0xFFFFFFFF;
176 u32 currindex;
177 struct vfield_reg_header vregheader;
178 struct vfield_reg_entry vregentry;
179 struct vfield_header vheader;
180 struct vfield_entry ventry;
181 union nv_pmu_bios_vfield_register_segment *psegment = NULL;
182 u8 *psegmentcount = NULL;
183 u32 status = 0;
184
185 if (g->ops.bios.get_perf_table_ptrs) {
186 vfieldregtableptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
187 g->bios.virt_token, VP_FIELD_REGISTER);
188 if (vfieldregtableptr == NULL) {
189 status = -EINVAL;
190 goto done;
191 }
192
193 vfieldtableptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
194 g->bios.virt_token, VP_FIELD_TABLE);
195 if (vfieldtableptr == NULL) {
196 status = -EINVAL;
197 goto done;
198 }
199 }
200
201 memcpy(&vregheader, vfieldregtableptr, VFIELD_REG_HEADER_SIZE);
202
203 if (vregheader.version != VBIOS_VFIELD_REG_TABLE_VERSION_1_0) {
204 gk20a_err(dev_from_gk20a(g), "invalid vreg header version");
205 goto done;
206 }
207
208 memcpy(&vheader, vfieldtableptr, VFIELD_HEADER_SIZE);
209
210 if (vregheader.version != VBIOS_VFIELD_TABLE_VERSION_1_0) {
211 gk20a_err(dev_from_gk20a(g), "invalid vfield header version");
212 goto done;
213 }
214
215 pvfevar->vfield_info.fuse.segment_count = 0;
216 pvfevar->vfield_ver_info.fuse.segment_count = 0;
217 for (i = 0; i < (u32)vheader.count; i++) {
218 memcpy(&ventry, vfieldtableptr + vfieldheadersize +
219 (i * vheader.entry_size),
220 vheader.entry_size);
221
222 currindex = VFIELD_BIT_REG(ventry);
223 if (currindex != oldindex) {
224
225 memcpy(&vregentry, vfieldregtableptr +
226 vfieldregheadersize +
227 (currindex * vregheader.entry_size),
228 vregheader.entry_size);
229 oldindex = currindex;
230 }
231
232 if (pvfevar->vfield_info.v_field_id == ventry.strap_id) {
233 psegmentcount =
234 &(pvfevar->vfield_info.fuse.segment_count);
235 psegment =
236 &(pvfevar->vfield_info.fuse.segments[*psegmentcount]);
237 if (*psegmentcount > NV_PMU_VFE_VAR_SINGLE_SENSED_FUSE_SEGMENTS_MAX) {
238 status = -EINVAL;
239 goto done;
240 }
241 } else if (pvfevar->vfield_ver_info.v_field_id_ver == ventry.strap_id) {
242 psegmentcount =
243 &(pvfevar->vfield_ver_info.fuse.segment_count);
244 psegment =
245 &(pvfevar->vfield_ver_info.fuse.segments[*psegmentcount]);
246 if (*psegmentcount > NV_PMU_VFE_VAR_SINGLE_SENSED_FUSE_SEGMENTS_MAX) {
247 status = -EINVAL;
248 goto done;
249 }
250 } else {
251 continue;
252 }
253
254 psegment->super.high_bit = (u8)(VFIELD_BIT_STOP(ventry));
255 psegment->super.low_bit = (u8)(VFIELD_BIT_START(ventry));
256 switch (VFIELD_CODE((&vregentry))) {
257 case NV_VFIELD_DESC_CODE_REG:
258 psegment->reg.super.type =
259 NV_PMU_BIOS_VFIELD_DESC_CODE_REG;
260 psegment->reg.addr = vregentry.reg;
261 break;
262
263 case NV_VFIELD_DESC_CODE_INDEX_REG:
264 psegment->index_reg.super.type =
265 NV_PMU_BIOS_VFIELD_DESC_CODE_INDEX_REG;
266 psegment->index_reg.addr = vregentry.reg;
267 psegment->index_reg.index = vregentry.index;
268 psegment->index_reg.reg_index = vregentry.reg_index;
269 break;
270
271 default:
272 psegment->super.type =
273 NV_PMU_BIOS_VFIELD_DESC_CODE_INVALID;
274 status = -EINVAL;
275 goto done;
276 }
277
278 if (VFIELD_SIZE((&vregentry)) != NV_VFIELD_DESC_SIZE_DWORD) {
279 psegment->super.type =
280 NV_PMU_BIOS_VFIELD_DESC_CODE_INVALID;
281 return -EINVAL;
282 }
283 (*psegmentcount)++;
284 }
285
286done:
287
288 return status;
289}
290
291static u32 _vfe_var_pmudatainit_super(struct gk20a *g,
292 struct boardobj *board_obj_ptr,
293 struct nv_pmu_boardobj *ppmudata)
294{
295 u32 status = 0;
296 struct vfe_var *pvfe_var;
297 struct nv_pmu_vfe_var *pset;
298
299 gk20a_dbg_info("");
300
301 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
302 if (status != 0)
303 return status;
304
305 pvfe_var = (struct vfe_var *)board_obj_ptr;
306 pset = (struct nv_pmu_vfe_var *) ppmudata;
307
308 pset->out_range_min = pvfe_var->out_range_min;
309 pset->out_range_max = pvfe_var->out_range_max;
310
311 return status;
312}
313
314static u32 vfe_var_construct_super(struct gk20a *g,
315 struct boardobj **ppboardobj,
316 u16 size, void *pargs)
317{
318 struct vfe_var *pvfevar;
319 struct vfe_var *ptmpvar = (struct vfe_var *)pargs;
320 u32 status = 0;
321
322 gk20a_dbg_info("");
323
324 status = boardobj_construct_super(g, ppboardobj, size, pargs);
325 if (status)
326 return -EINVAL;
327
328 pvfevar = (struct vfe_var *)*ppboardobj;
329
330 pvfevar->super.pmudatainit =
331 _vfe_var_pmudatainit_super;
332
333 pvfevar->out_range_min = ptmpvar->out_range_min;
334 pvfevar->out_range_max = ptmpvar->out_range_max;
335 pvfevar->b_is_dynamic_valid = false;
336
337 gk20a_dbg_info("");
338
339 return status;
340}
341
342static u32 _vfe_var_pmudatainit_derived(struct gk20a *g,
343 struct boardobj *board_obj_ptr,
344 struct nv_pmu_boardobj *ppmudata)
345{
346 u32 status = 0;
347
348 gk20a_dbg_info("");
349
350 status = _vfe_var_pmudatainit_super(g, board_obj_ptr, ppmudata);
351
352 return status;
353}
354
355static u32 vfe_var_construct_derived(struct gk20a *g,
356 struct boardobj **ppboardobj,
357 u16 size, void *pargs)
358{
359 struct boardobj *ptmpobj = (struct boardobj *)pargs;
360 u32 status = 0;
361 struct vfe_var_derived *pvfevar;
362
363 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_VAR_TYPE_DERIVED);
364 status = vfe_var_construct_super(g, ppboardobj, size, pargs);
365 if (status)
366 return -EINVAL;
367
368 pvfevar = (struct vfe_var_derived *)*ppboardobj;
369
370 pvfevar->super.super.pmudatainit =
371 _vfe_var_pmudatainit_derived;
372
373 return status;
374}
375
376static u32 _vfe_var_pmudatainit_derived_product(struct gk20a *g,
377 struct boardobj *board_obj_ptr,
378 struct nv_pmu_boardobj *ppmudata)
379{
380 u32 status = 0;
381 struct vfe_var_derived_product *pvfe_var_derived_product;
382 struct nv_pmu_vfe_var_derived_product *pset;
383
384 gk20a_dbg_info("");
385
386 status = _vfe_var_pmudatainit_derived(g, board_obj_ptr, ppmudata);
387 if (status != 0)
388 return status;
389
390 pvfe_var_derived_product =
391 (struct vfe_var_derived_product *)board_obj_ptr;
392 pset = (struct nv_pmu_vfe_var_derived_product *)ppmudata;
393
394 pset->var_idx0 = pvfe_var_derived_product->var_idx0;
395 pset->var_idx1 = pvfe_var_derived_product->var_idx1;
396
397 return status;
398}
399
400static u32 vfe_var_construct_derived_product(struct gk20a *g,
401 struct boardobj **ppboardobj,
402 u16 size, void *pargs)
403{
404 struct boardobj *ptmpobj = (struct boardobj *)pargs;
405 struct vfe_var_derived_product *pvfevar;
406 struct vfe_var_derived_product *ptmpvar =
407 (struct vfe_var_derived_product *)pargs;
408 u32 status = 0;
409
410 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_PERF_VFE_VAR_TYPE_DERIVED_PRODUCT)
411 return -EINVAL;
412
413 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_VAR_TYPE_DERIVED_PRODUCT);
414 status = vfe_var_construct_derived(g, ppboardobj, size, pargs);
415 if (status)
416 return -EINVAL;
417
418 pvfevar = (struct vfe_var_derived_product *)*ppboardobj;
419
420 pvfevar->super.super.super.pmudatainit =
421 _vfe_var_pmudatainit_derived_product;
422
423 pvfevar->var_idx0 = ptmpvar->var_idx0;
424 pvfevar->var_idx1 = ptmpvar->var_idx1;
425
426
427 return status;
428}
429
430static u32 _vfe_var_pmudatainit_derived_sum(struct gk20a *g,
431 struct boardobj *board_obj_ptr,
432 struct nv_pmu_boardobj *ppmudata)
433{
434 u32 status = 0;
435 struct vfe_var_derived_sum *pvfe_var_derived_sum;
436 struct nv_pmu_vfe_var_derived_sum *pset;
437
438 gk20a_dbg_info("");
439
440 status = _vfe_var_pmudatainit_derived(g, board_obj_ptr, ppmudata);
441 if (status != 0)
442 return status;
443
444 pvfe_var_derived_sum = (struct vfe_var_derived_sum *)board_obj_ptr;
445 pset = (struct nv_pmu_vfe_var_derived_sum *)ppmudata;
446
447 pset->var_idx0 = pvfe_var_derived_sum->var_idx0;
448 pset->var_idx1 = pvfe_var_derived_sum->var_idx1;
449
450 return status;
451}
452
453static u32 vfe_var_construct_derived_sum(struct gk20a *g,
454 struct boardobj **ppboardobj,
455 u16 size, void *pargs)
456{
457 struct boardobj *ptmpobj = (struct boardobj *)pargs;
458 struct vfe_var_derived_sum *pvfevar;
459 struct vfe_var_derived_sum *ptmpvar =
460 (struct vfe_var_derived_sum *)pargs;
461 u32 status = 0;
462
463 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_PERF_VFE_VAR_TYPE_DERIVED_SUM)
464 return -EINVAL;
465
466 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_VAR_TYPE_DERIVED_SUM);
467 status = vfe_var_construct_derived(g, ppboardobj, size, pargs);
468 if (status)
469 return -EINVAL;
470
471 pvfevar = (struct vfe_var_derived_sum *)*ppboardobj;
472
473 pvfevar->super.super.super.pmudatainit =
474 _vfe_var_pmudatainit_derived_sum;
475
476 pvfevar->var_idx0 = ptmpvar->var_idx0;
477 pvfevar->var_idx1 = ptmpvar->var_idx1;
478
479 return status;
480}
481
482static u32 _vfe_var_pmudatainit_single(struct gk20a *g,
483 struct boardobj *board_obj_ptr,
484 struct nv_pmu_boardobj *ppmudata)
485{
486 u32 status = 0;
487 struct vfe_var_single *pvfe_var_single;
488 struct nv_pmu_vfe_var_single *pset;
489
490 gk20a_dbg_info("");
491
492 status = _vfe_var_pmudatainit_super(g, board_obj_ptr, ppmudata);
493 if (status != 0)
494 return status;
495
496 pvfe_var_single = (struct vfe_var_single *)board_obj_ptr;
497 pset = (struct nv_pmu_vfe_var_single *)
498 ppmudata;
499
500 pset->override_type = pvfe_var_single->override_type;
501 pset->override_value = pvfe_var_single->override_value;
502
503 return status;
504}
505
506static u32 _vfe_var_pmudatainit_single_frequency(struct gk20a *g,
507 struct boardobj *board_obj_ptr,
508 struct nv_pmu_boardobj *ppmudata)
509{
510 u32 status = 0;
511
512 gk20a_dbg_info("");
513
514 status = _vfe_var_pmudatainit_single(g, board_obj_ptr, ppmudata);
515
516 return status;
517}
518
519static u32 vfe_var_construct_single_frequency(struct gk20a *g,
520 struct boardobj **ppboardobj,
521 u16 size, void *pargs)
522{
523 struct boardobj *ptmpobj = (struct boardobj *)pargs;
524 struct vfe_var_single_frequency *pvfevar;
525 u32 status = 0;
526
527 gk20a_dbg_info("");
528
529 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_PERF_VFE_VAR_TYPE_SINGLE_FREQUENCY)
530 return -EINVAL;
531
532 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_VAR_TYPE_SINGLE_FREQUENCY);
533 status = vfe_var_construct_single(g, ppboardobj, size, pargs);
534 if (status)
535 return -EINVAL;
536
537 pvfevar = (struct vfe_var_single_frequency *)*ppboardobj;
538
539 pvfevar->super.super.super.pmudatainit =
540 _vfe_var_pmudatainit_single_frequency;
541
542 pvfevar->super.super.b_is_dynamic = false;
543 pvfevar->super.super.b_is_dynamic_valid = true;
544
545 gk20a_dbg_info("Done");
546 return status;
547}
548
549static u32 _vfe_var_pmudatainit_single_sensed(struct gk20a *g,
550 struct boardobj *board_obj_ptr,
551 struct nv_pmu_boardobj *ppmudata)
552{
553 u32 status = 0;
554
555 gk20a_dbg_info("");
556
557 status = _vfe_var_pmudatainit_single(g, board_obj_ptr, ppmudata);
558
559 return status;
560}
561
562static u32 _vfe_var_pmudatainit_single_sensed_fuse(struct gk20a *g,
563 struct boardobj *board_obj_ptr,
564 struct nv_pmu_boardobj *ppmudata)
565{
566 u32 status = 0;
567 struct vfe_var_single_sensed_fuse *pvfe_var_single_sensed_fuse;
568 struct nv_pmu_vfe_var_single_sensed_fuse *pset;
569
570 gk20a_dbg_info("");
571
572 status = _vfe_var_pmudatainit_single_sensed(g, board_obj_ptr, ppmudata);
573 if (status != 0)
574 return status;
575
576 pvfe_var_single_sensed_fuse =
577 (struct vfe_var_single_sensed_fuse *)board_obj_ptr;
578
579 pset = (struct nv_pmu_vfe_var_single_sensed_fuse *)
580 ppmudata;
581
582 memcpy(&pset->vfield_info, &pvfe_var_single_sensed_fuse->vfield_info,
583 sizeof(struct nv_pmu_vfe_var_single_sensed_fuse_vfield_info));
584
585 memcpy(&pset->vfield_ver_info,
586 &pvfe_var_single_sensed_fuse->vfield_ver_info,
587 sizeof(struct nv_pmu_vfe_var_single_sensed_fuse_ver_vfield_info));
588
589 memcpy(&pset->override_info,
590 &pvfe_var_single_sensed_fuse->override_info,
591 sizeof(struct nv_pmu_vfe_var_single_sensed_fuse_override_info));
592
593 return status;
594}
595
596static u32 vfe_var_construct_single_sensed(struct gk20a *g,
597 struct boardobj **ppboardobj,
598 u16 size, void *pargs)
599{
600 struct boardobj *ptmpobj = (struct boardobj *)pargs;
601 struct vfe_var_single_sensed *pvfevar;
602
603 u32 status = 0;
604
605 gk20a_dbg_info(" ");
606
607 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED);
608 status = vfe_var_construct_single(g, ppboardobj, size, pargs);
609 if (status)
610 return -EINVAL;
611
612 pvfevar = (struct vfe_var_single_sensed *)*ppboardobj;
613
614 pvfevar->super.super.super.pmudatainit =
615 _vfe_var_pmudatainit_single_sensed;
616
617 gk20a_dbg_info("Done");
618
619 return status;
620}
621
622static u32 vfe_var_construct_single_sensed_fuse(struct gk20a *g,
623 struct boardobj **ppboardobj,
624 u16 size, void *pargs)
625{
626 struct boardobj *ptmpobj = (struct boardobj *)pargs;
627 struct vfe_var_single_sensed_fuse *pvfevar;
628 struct vfe_var_single_sensed_fuse *ptmpvar =
629 (struct vfe_var_single_sensed_fuse *)pargs;
630 u32 status = 0;
631
632 gk20a_dbg_info("");
633
634 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_FUSE)
635 return -EINVAL;
636
637 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_FUSE);
638 status = vfe_var_construct_single_sensed(g, ppboardobj, size, pargs);
639 if (status)
640 return -EINVAL;
641
642 pvfevar = (struct vfe_var_single_sensed_fuse *)*ppboardobj;
643
644 pvfevar->super.super.super.super.pmudatainit =
645 _vfe_var_pmudatainit_single_sensed_fuse;
646
647 pvfevar->vfield_info.v_field_id = ptmpvar->vfield_info.v_field_id;
648 pvfevar->vfield_info.fuse_val_default =
649 ptmpvar->vfield_info.fuse_val_default;
650 pvfevar->vfield_info.hw_correction_scale =
651 ptmpvar->vfield_info.hw_correction_scale;
652 pvfevar->vfield_info.hw_correction_offset =
653 ptmpvar->vfield_info.hw_correction_offset;
654 pvfevar->vfield_ver_info.v_field_id_ver =
655 ptmpvar->vfield_ver_info.v_field_id_ver;
656 pvfevar->vfield_ver_info.ver_expected =
657 ptmpvar->vfield_ver_info.ver_expected;
658 pvfevar->vfield_ver_info.b_use_default_on_ver_check_fail =
659 ptmpvar->vfield_ver_info.b_use_default_on_ver_check_fail;
660 pvfevar->b_version_check_done = false;
661
662 pvfevar->super.super.super.b_is_dynamic = false;
663 pvfevar->super.super.super.b_is_dynamic_valid = true;
664
665 dev_init_get_vfield_info(g, pvfevar);
666 /*check whether fuse segment got initialized*/
667 if (pvfevar->vfield_info.fuse.segment_count == 0) {
668 gk20a_err(dev_from_gk20a(g), "unable to get fuse reg info %x",
669 pvfevar->vfield_info.v_field_id);
670 return -EINVAL;
671 }
672 if (pvfevar->vfield_ver_info.fuse.segment_count == 0) {
673 gk20a_err(dev_from_gk20a(g), "unable to get fuse reg info %x",
674 pvfevar->vfield_ver_info.v_field_id_ver);
675 return -EINVAL;
676 }
677 return status;
678}
679
680static u32 _vfe_var_pmudatainit_single_sensed_temp(struct gk20a *g,
681 struct boardobj *board_obj_ptr,
682 struct nv_pmu_boardobj *ppmudata)
683{
684 u32 status = 0;
685 struct vfe_var_single_sensed_temp *pvfe_var_single_sensed_temp;
686 struct nv_pmu_vfe_var_single_sensed_temp *pset;
687
688 gk20a_dbg_info("");
689
690 status = _vfe_var_pmudatainit_single_sensed(g, board_obj_ptr, ppmudata);
691 if (status != 0)
692 return status;
693
694 pvfe_var_single_sensed_temp =
695 (struct vfe_var_single_sensed_temp *)board_obj_ptr;
696
697 pset = (struct nv_pmu_vfe_var_single_sensed_temp *)
698 ppmudata;
699 pset->therm_channel_index =
700 pvfe_var_single_sensed_temp->therm_channel_index;
701 pset->temp_hysteresis_positive =
702 pvfe_var_single_sensed_temp->temp_hysteresis_positive;
703 pset->temp_hysteresis_negative =
704 pvfe_var_single_sensed_temp->temp_hysteresis_negative;
705 pset->temp_default =
706 pvfe_var_single_sensed_temp->temp_default;
707 return status;
708}
709
710static u32 vfe_var_construct_single_sensed_temp(struct gk20a *g,
711 struct boardobj **ppboardobj,
712 u16 size, void *pargs)
713{
714 struct boardobj *ptmpobj = (struct boardobj *)pargs;
715 struct vfe_var_single_sensed_temp *pvfevar;
716 struct vfe_var_single_sensed_temp *ptmpvar =
717 (struct vfe_var_single_sensed_temp *)pargs;
718 u32 status = 0;
719
720 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_TEMP)
721 return -EINVAL;
722
723 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_TEMP);
724 status = vfe_var_construct_single_sensed(g, ppboardobj, size, pargs);
725 if (status)
726 return -EINVAL;
727
728 pvfevar = (struct vfe_var_single_sensed_temp *)*ppboardobj;
729
730 pvfevar->super.super.super.super.pmudatainit =
731 _vfe_var_pmudatainit_single_sensed_temp;
732
733 pvfevar->therm_channel_index =
734 ptmpvar->therm_channel_index;
735 pvfevar->temp_hysteresis_positive =
736 ptmpvar->temp_hysteresis_positive;
737 pvfevar->temp_hysteresis_negative =
738 ptmpvar->temp_hysteresis_negative;
739 pvfevar->temp_default =
740 ptmpvar->temp_default;
741 pvfevar->super.super.super.b_is_dynamic = false;
742 pvfevar->super.super.super.b_is_dynamic_valid = true;
743
744 return status;
745}
746
747static u32 _vfe_var_pmudatainit_single_voltage(struct gk20a *g,
748 struct boardobj *board_obj_ptr,
749 struct nv_pmu_boardobj *ppmudata)
750{
751 u32 status = 0;
752
753 gk20a_dbg_info("");
754
755 status = _vfe_var_pmudatainit_single(g, board_obj_ptr, ppmudata);
756
757 return status;
758}
759
760static u32 vfe_var_construct_single_voltage(struct gk20a *g,
761 struct boardobj **ppboardobj,
762 u16 size, void *pargs)
763{
764 struct boardobj *ptmpobj = (struct boardobj *)pargs;
765 struct vfe_var_single_voltage *pvfevar;
766 u32 status = 0;
767
768 if (BOARDOBJ_GET_TYPE(pargs) != CTRL_PERF_VFE_VAR_TYPE_SINGLE_VOLTAGE)
769 return -EINVAL;
770
771 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_VAR_TYPE_SINGLE_VOLTAGE);
772 status = vfe_var_construct_super(g, ppboardobj, size, pargs);
773 if (status)
774 return -EINVAL;
775
776 pvfevar = (struct vfe_var_single_voltage *)*ppboardobj;
777
778 pvfevar->super.super.super.pmudatainit =
779 _vfe_var_pmudatainit_single_voltage;
780
781 pvfevar->super.super.b_is_dynamic = false;
782 pvfevar->super.super.b_is_dynamic_valid = true;
783
784 return status;
785}
786
787static struct vfe_var *construct_vfe_var(struct gk20a *g, void *pargs)
788{
789 struct boardobj *board_obj_ptr = NULL;
790 u32 status;
791
792 gk20a_dbg_info("");
793 switch (BOARDOBJ_GET_TYPE(pargs)) {
794 case CTRL_PERF_VFE_VAR_TYPE_DERIVED_PRODUCT:
795 status = vfe_var_construct_derived_product(g, &board_obj_ptr,
796 sizeof(struct vfe_var_derived_product), pargs);
797 break;
798
799 case CTRL_PERF_VFE_VAR_TYPE_DERIVED_SUM:
800 status = vfe_var_construct_derived_sum(g, &board_obj_ptr,
801 sizeof(struct vfe_var_derived_sum), pargs);
802 break;
803
804 case CTRL_PERF_VFE_VAR_TYPE_SINGLE_FREQUENCY:
805 status = vfe_var_construct_single_frequency(g, &board_obj_ptr,
806 sizeof(struct vfe_var_single_frequency), pargs);
807 break;
808
809 case CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_FUSE:
810 status = vfe_var_construct_single_sensed_fuse(g, &board_obj_ptr,
811 sizeof(struct vfe_var_single_sensed_fuse), pargs);
812 break;
813
814 case CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_TEMP:
815 status = vfe_var_construct_single_sensed_temp(g, &board_obj_ptr,
816 sizeof(struct vfe_var_single_sensed_temp), pargs);
817 break;
818
819 case CTRL_PERF_VFE_VAR_TYPE_SINGLE_VOLTAGE:
820 status = vfe_var_construct_single_voltage(g, &board_obj_ptr,
821 sizeof(struct vfe_var_single_voltage), pargs);
822 break;
823
824 case CTRL_PERF_VFE_VAR_TYPE_DERIVED:
825 case CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED:
826 case CTRL_PERF_VFE_VAR_TYPE_SINGLE:
827 default:
828 return NULL;
829 }
830
831 if (status)
832 return NULL;
833
834 gk20a_dbg_info("done");
835
836 return (struct vfe_var *)board_obj_ptr;
837}
838
839static u32 devinit_get_vfe_var_table(struct gk20a *g,
840 struct vfe_vars *pvfevarobjs)
841{
842 u32 status = 0;
843 u8 *vfevars_tbl_ptr = NULL;
844 struct vbios_vfe_3x_header_struct vfevars_tbl_header = { 0 };
845 struct vbios_vfe_3x_var_entry_struct var = { 0 };
846 u8 *vfevars_tbl_entry_ptr = NULL;
847 u8 *rd_offset_ptr = NULL;
848 u32 index = 0;
849 struct vfe_var *pvar;
850 u8 var_type;
851 u32 szfmt;
852 union {
853 struct boardobj board_obj;
854 struct vfe_var super;
855 struct vfe_var_derived_product derived_product;
856 struct vfe_var_derived_sum derived_sum;
857 struct vfe_var_single_sensed_fuse single_sensed_fuse;
858 struct vfe_var_single_sensed_temp single_sensed_temp;
859 } var_data;
860
861 gk20a_dbg_info("");
862
863 if (g->ops.bios.get_perf_table_ptrs) {
864 vfevars_tbl_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
865 g->bios.perf_token,
866 CONTINUOUS_VIRTUAL_BINNING_TABLE);
867 if (vfevars_tbl_ptr == NULL) {
868 status = -EINVAL;
869 goto done;
870 }
871 }
872
873 memcpy(&vfevars_tbl_header, vfevars_tbl_ptr,
874 VBIOS_CLOCKS_TABLE_1X_HEADER_SIZE_07);
875 if (vfevars_tbl_header.header_size !=
876 VBIOS_CLOCKS_TABLE_1X_HEADER_SIZE_07){
877 status = -EINVAL;
878 goto done;
879 }
880
881 if (vfevars_tbl_header.vfe_var_entry_size ==
882 VBIOS_VFE_3X_VAR_ENTRY_SIZE_19)
883 szfmt = VBIOS_VFE_3X_VAR_ENTRY_SIZE_19;
884 else if (vfevars_tbl_header.vfe_var_entry_size ==
885 VBIOS_VFE_3X_VAR_ENTRY_SIZE_11)
886 szfmt = VBIOS_VFE_3X_VAR_ENTRY_SIZE_11;
887 else {
888 status = -EINVAL;
889 goto done;
890 }
891
892 /* Read table entries*/
893 vfevars_tbl_entry_ptr = vfevars_tbl_ptr +
894 vfevars_tbl_header.header_size;
895
896 for (index = 0;
897 index < vfevars_tbl_header.vfe_var_entry_count;
898 index++) {
899 rd_offset_ptr = vfevars_tbl_entry_ptr +
900 (index * vfevars_tbl_header.vfe_var_entry_size);
901 memcpy(&var, rd_offset_ptr, szfmt);
902
903 var_data.super.out_range_min = var.out_range_min;
904 var_data.super.out_range_max = var.out_range_max;
905
906 var_data.super.out_range_min = var.out_range_min;
907 var_data.super.out_range_max = var.out_range_max;
908
909 switch ((u8)var.type) {
910 case VBIOS_VFE_3X_VAR_ENTRY_TYPE_DISABLED:
911 continue;
912 break;
913
914 case VBIOS_VFE_3X_VAR_ENTRY_TYPE_SINGLE_FREQUENCY:
915 var_type = CTRL_PERF_VFE_VAR_TYPE_SINGLE_FREQUENCY;
916 break;
917
918 case VBIOS_VFE_3X_VAR_ENTRY_TYPE_SINGLE_VOLTAGE:
919 var_type = CTRL_PERF_VFE_VAR_TYPE_SINGLE_VOLTAGE;
920 break;
921
922 case VBIOS_VFE_3X_VAR_ENTRY_TYPE_SINGLE_SENSED_TEMP:
923 var_type = CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_TEMP;
924 var_data.single_sensed_temp.temp_default = 0x9600;
925 var_data.single_sensed_temp.therm_channel_index =
926 (u8)BIOS_GET_FIELD(var.param0,
927 VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSTEMP_TH_CH_IDX);
928 var_data.single_sensed_temp.temp_hysteresis_positive =
929 (u8)BIOS_GET_FIELD(var.param0,
930 VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSTEMP_HYS_POS) << 5;
931 var_data.single_sensed_temp.temp_hysteresis_negative =
932 (u8)BIOS_GET_FIELD(var.param0,
933 VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSTEMP_HYS_NEG) << 5;
934 break;
935
936 case VBIOS_VFE_3X_VAR_ENTRY_TYPE_SINGLE_SENSED_FUSE:
937 var_type = CTRL_PERF_VFE_VAR_TYPE_SINGLE_SENSED_FUSE;
938 var_data.single_sensed_fuse.vfield_info.v_field_id =
939 (u8)BIOS_GET_FIELD(var.param0,
940 VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_VFIELD_ID);
941 var_data.single_sensed_fuse.vfield_ver_info.v_field_id_ver =
942 (u8)BIOS_GET_FIELD(var.param0,
943 VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_VFIELD_ID_VER);
944 var_data.single_sensed_fuse.vfield_ver_info.ver_expected =
945 (u8)BIOS_GET_FIELD(var.param0,
946 VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_EXPECTED_VER);
947 var_data.single_sensed_fuse.vfield_ver_info.b_use_default_on_ver_check_fail =
948 (BIOS_GET_FIELD(var.param0,
949 VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_USE_DEFAULT_ON_VER_CHECK_FAIL) &&
950 VBIOS_VFE_3X_VAR_ENTRY_PAR0_SSFUSE_USE_DEFAULT_ON_VER_CHECK_FAIL_YES);
951 var_data.single_sensed_fuse.vfield_info.fuse_val_default =
952 var.param1;
953 if (szfmt >= VBIOS_VFE_3X_VAR_ENTRY_SIZE_19) {
954 var_data.single_sensed_fuse.vfield_info.hw_correction_scale =
955 (int)var.param2;
956 var_data.single_sensed_fuse.vfield_info.hw_correction_offset =
957 var.param3;
958 } else {
959 var_data.single_sensed_fuse.vfield_info.hw_correction_scale =
960 1 << 12;
961 var_data.single_sensed_fuse.vfield_info.hw_correction_offset =
962 0;
963 if ((var_data.single_sensed_fuse.vfield_info.v_field_id ==
964 VFIELD_ID_STRAP_IDDQ) ||
965 (var_data.single_sensed_fuse.vfield_info.v_field_id ==
966 VFIELD_ID_STRAP_IDDQ_1)) {
967 var_data.single_sensed_fuse.vfield_info.hw_correction_scale =
968 50 << 12;
969 }
970 }
971 break;
972
973 case VBIOS_VFE_3X_VAR_ENTRY_TYPE_DERIVED_PRODUCT:
974 var_type = CTRL_PERF_VFE_VAR_TYPE_DERIVED_PRODUCT;
975 var_data.derived_product.var_idx0 =
976 (u8)BIOS_GET_FIELD(var.param0,
977 VBIOS_VFE_3X_VAR_ENTRY_PAR0_DPROD_VFE_VAR_IDX_0);
978 var_data.derived_product.var_idx1 =
979 (u8)BIOS_GET_FIELD(var.param0,
980 VBIOS_VFE_3X_VAR_ENTRY_PAR0_DPROD_VFE_VAR_IDX_1);
981 break;
982
983 case VBIOS_VFE_3X_VAR_ENTRY_TYPE_DERIVED_SUM:
984 var_type = CTRL_PERF_VFE_VAR_TYPE_DERIVED_SUM;
985 var_data.derived_sum.var_idx0 =
986 (u8)BIOS_GET_FIELD(var.param0,
987 VBIOS_VFE_3X_VAR_ENTRY_PAR0_DSUM_VFE_VAR_IDX_0);
988 var_data.derived_sum.var_idx1 =
989 (u8)BIOS_GET_FIELD(var.param0,
990 VBIOS_VFE_3X_VAR_ENTRY_PAR0_DSUM_VFE_VAR_IDX_1);
991 break;
992 default:
993 status = -EINVAL;
994 goto done;
995 }
996 var_data.board_obj.type = var_type;
997 var_data.board_obj.type_mask = 0;
998
999 pvar = construct_vfe_var(g, &var_data);
1000 if (pvar == NULL) {
1001 gk20a_err(dev_from_gk20a(g),
1002 "error constructing vfe_var boardobj %d",
1003 index);
1004 status = -EINVAL;
1005 goto done;
1006 }
1007
1008 status = boardobjgrp_objinsert(&pvfevarobjs->super.super,
1009 (struct boardobj *)pvar, index);
1010 if (status) {
1011 gk20a_err(dev_from_gk20a(g),
1012 "error adding vfe_var boardobj %d", index);
1013 status = -EINVAL;
1014 goto done;
1015 }
1016 }
1017 pvfevarobjs->polling_periodms = vfevars_tbl_header.polling_periodms;
1018done:
1019 gk20a_dbg_info("done status %x", status);
1020 return status;
1021}
1022
1023static u32 vfe_var_construct_single(struct gk20a *g,
1024 struct boardobj **ppboardobj,
1025 u16 size, void *pargs)
1026{
1027 struct boardobj *ptmpobj = (struct boardobj *)pargs;
1028 struct vfe_var_single *pvfevar;
1029 u32 status = 0;
1030
1031 gk20a_dbg_info("");
1032
1033 ptmpobj->type_mask |= BIT(CTRL_PERF_VFE_VAR_TYPE_SINGLE);
1034 status = vfe_var_construct_super(g, ppboardobj, size, pargs);
1035 if (status)
1036 return -EINVAL;
1037
1038 pvfevar = (struct vfe_var_single *)*ppboardobj;
1039
1040 pvfevar->super.super.pmudatainit =
1041 _vfe_var_pmudatainit_single;
1042
1043 pvfevar->override_type = CTRL_PERF_VFE_VAR_SINGLE_OVERRIDE_TYPE_NONE;
1044 pvfevar->override_value = 0;
1045
1046 gk20a_dbg_info("Done");
1047 return status;
1048}
diff --git a/drivers/gpu/nvgpu/perf/vfe_var.h b/drivers/gpu/nvgpu/perf/vfe_var.h
new file mode 100644
index 00000000..fc43311b
--- /dev/null
+++ b/drivers/gpu/nvgpu/perf/vfe_var.h
@@ -0,0 +1,97 @@
1/*
2 * Copyright (c) 2016, 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
14#ifndef _VFE_VAR_H_
15#define _VFE_VAR_H_
16
17#include "boardobj/boardobjgrp.h"
18#include "pmuif/gpmuifperf.h"
19#include "pmuif/gpmuifperfvfe.h"
20
21u32 vfe_var_sw_setup(struct gk20a *g);
22u32 vfe_var_pmu_setup(struct gk20a *g);
23
24#define VFE_VAR_GET(_pperf, _idx) \
25 ((struct vfe_var)BOARDOBJGRP_OBJ_GET_BY_IDX( \
26 &((_pperf)->vfe.vars.super.super), (_idx)))
27
28#define VFE_VAR_IDX_IS_VALID(_pperf, _idx) \
29 boardobjgrp_idxisvalid(&((_pperf)->vfe.vars.super.super), (_idx))
30
31struct vfe_var {
32 struct boardobj super;
33 u32 out_range_min;
34 u32 out_range_max;
35 bool b_is_dynamic_valid;
36 bool b_is_dynamic;
37};
38
39struct vfe_vars {
40 struct boardobjgrp_e32 super;
41 u8 polling_periodms;
42};
43
44struct vfe_var_derived {
45 struct vfe_var super;
46};
47
48struct vfe_var_derived_product {
49 struct vfe_var_derived super;
50 u8 var_idx0;
51 u8 var_idx1;
52};
53
54struct vfe_var_derived_sum {
55 struct vfe_var_derived super;
56 u8 var_idx0;
57 u8 var_idx1;
58};
59
60struct vfe_var_single {
61 struct vfe_var super;
62 u8 override_type;
63 u32 override_value;
64};
65
66struct vfe_var_single_frequency {
67 struct vfe_var_single super;
68};
69
70struct vfe_var_single_voltage {
71 struct vfe_var_single super;
72};
73
74struct vfe_var_single_sensed {
75 struct vfe_var_single super;
76};
77
78struct vfe_var_single_sensed_fuse {
79 struct vfe_var_single_sensed super;
80 struct nv_pmu_vfe_var_single_sensed_fuse_override_info override_info;
81 struct nv_pmu_vfe_var_single_sensed_fuse_vfield_info vfield_info;
82 struct nv_pmu_vfe_var_single_sensed_fuse_ver_vfield_info vfield_ver_info;
83 u32 fuse_value_integer;
84 u32 fuse_value_hw_integer;
85 u8 fuse_version;
86 bool b_version_check_done;
87};
88
89struct vfe_var_single_sensed_temp {
90 struct vfe_var_single_sensed super;
91 u8 therm_channel_index;
92 int temp_hysteresis_positive;
93 int temp_hysteresis_negative;
94 int temp_default;
95};
96
97#endif
diff --git a/drivers/gpu/nvgpu/pmgr/pmgr.c b/drivers/gpu/nvgpu/pmgr/pmgr.c
new file mode 100644
index 00000000..e101aba8
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pmgr.c
@@ -0,0 +1,176 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "pwrdev.h"
16#include "pmgrpmu.h"
17#include <linux/debugfs.h>
18
19int pmgr_pwr_devices_get_power(struct gk20a *g, u32 *val)
20{
21 struct nv_pmu_pmgr_pwr_devices_query_payload payload;
22 int status;
23
24 status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload);
25 if (status)
26 gk20a_err(dev_from_gk20a(g),
27 "pmgr_pwr_devices_get_current_power failed %x",
28 status);
29
30 *val = payload.devices[0].powerm_w;
31
32 return status;
33}
34
35int pmgr_pwr_devices_get_current(struct gk20a *g, u32 *val)
36{
37 struct nv_pmu_pmgr_pwr_devices_query_payload payload;
38 int status;
39
40 status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload);
41 if (status)
42 gk20a_err(dev_from_gk20a(g),
43 "pmgr_pwr_devices_get_current failed %x",
44 status);
45
46 *val = payload.devices[0].currentm_a;
47
48 return status;
49}
50
51int pmgr_pwr_devices_get_voltage(struct gk20a *g, u32 *val)
52{
53 struct nv_pmu_pmgr_pwr_devices_query_payload payload;
54 int status;
55
56 status = pmgr_pmu_pwr_devices_query_blocking(g, 1, &payload);
57 if (status)
58 gk20a_err(dev_from_gk20a(g),
59 "pmgr_pwr_devices_get_current_voltage failed %x",
60 status);
61
62 *val = payload.devices[0].voltageu_v;
63
64 return status;
65}
66
67#ifdef CONFIG_DEBUG_FS
68int pmgr_pwr_devices_get_power_u64(void *data, u64 *p)
69{
70 struct gk20a *g = (struct gk20a *)data;
71 int err;
72 u32 val;
73
74 err = pmgr_pwr_devices_get_power(g, &val);
75 *p = val;
76
77 return err;
78}
79
80int pmgr_pwr_devices_get_current_u64(void *data, u64 *p)
81{
82 struct gk20a *g = (struct gk20a *)data;
83 int err;
84 u32 val;
85
86 err = pmgr_pwr_devices_get_current(g, &val);
87 *p = val;
88
89 return err;
90}
91
92int pmgr_pwr_devices_get_voltage_u64(void *data, u64 *p)
93{
94 struct gk20a *g = (struct gk20a *)data;
95 int err;
96 u32 val;
97
98 err = pmgr_pwr_devices_get_voltage(g, &val);
99 *p = val;
100
101 return err;
102}
103
104DEFINE_SIMPLE_ATTRIBUTE(
105 pmgr_power_ctrl_fops, pmgr_pwr_devices_get_power_u64, NULL, "%llu\n");
106
107DEFINE_SIMPLE_ATTRIBUTE(
108 pmgr_current_ctrl_fops, pmgr_pwr_devices_get_current_u64, NULL, "%llu\n");
109
110DEFINE_SIMPLE_ATTRIBUTE(
111 pmgr_voltage_ctrl_fops, pmgr_pwr_devices_get_voltage_u64, NULL, "%llu\n");
112
113static void pmgr_debugfs_init(struct gk20a *g) {
114 struct gk20a_platform *platform = dev_get_drvdata(g->dev);
115 struct dentry *dbgentry;
116
117 dbgentry = debugfs_create_file(
118 "power", S_IRUGO, platform->debugfs, g, &pmgr_power_ctrl_fops);
119 if (!dbgentry)
120 gk20a_err(dev_from_gk20a(g),
121 "debugfs entry create failed for power");
122
123 dbgentry = debugfs_create_file(
124 "current", S_IRUGO, platform->debugfs, g, &pmgr_current_ctrl_fops);
125 if (!dbgentry)
126 gk20a_err(dev_from_gk20a(g),
127 "debugfs entry create failed for current");
128
129 dbgentry = debugfs_create_file(
130 "voltage", S_IRUGO, platform->debugfs, g, &pmgr_voltage_ctrl_fops);
131 if (!dbgentry)
132 gk20a_err(dev_from_gk20a(g),
133 "debugfs entry create failed for voltage");
134}
135#endif
136
137u32 pmgr_domain_sw_setup(struct gk20a *g)
138{
139 u32 status;
140
141 status = pmgr_device_sw_setup(g);
142 if (status) {
143 gk20a_err(dev_from_gk20a(g),
144 "error creating boardobjgrp for pmgr devices, status - 0x%x",
145 status);
146 goto exit;
147 }
148
149 status = pmgr_monitor_sw_setup(g);
150 if (status) {
151 gk20a_err(dev_from_gk20a(g),
152 "error creating boardobjgrp for pmgr monitor, status - 0x%x",
153 status);
154 goto exit;
155 }
156
157 status = pmgr_policy_sw_setup(g);
158 if (status) {
159 gk20a_err(dev_from_gk20a(g),
160 "error creating boardobjgrp for pmgr policy, status - 0x%x",
161 status);
162 goto exit;
163 }
164
165#ifdef CONFIG_DEBUG_FS
166 pmgr_debugfs_init(g);
167#endif
168
169exit:
170 return status;
171}
172
173u32 pmgr_domain_pmu_setup(struct gk20a *g)
174{
175 return pmgr_send_pmgr_tables_to_pmu(g);
176}
diff --git a/drivers/gpu/nvgpu/pmgr/pmgr.h b/drivers/gpu/nvgpu/pmgr/pmgr.h
new file mode 100644
index 00000000..cf511fd1
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pmgr.h
@@ -0,0 +1,34 @@
1/*
2 * general power device structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _PMGR_H_
16#define _PMGR_H_
17
18#include "pwrdev.h"
19#include "pwrmonitor.h"
20#include "pwrpolicy.h"
21
22struct pmgr_pmupstate {
23 struct pwr_devices pmgr_deviceobjs;
24 struct pmgr_pwr_monitor pmgr_monitorobjs;
25 struct pmgr_pwr_policy pmgr_policyobjs;
26};
27
28u32 pmgr_domain_sw_setup(struct gk20a *g);
29u32 pmgr_domain_pmu_setup(struct gk20a *g);
30int pmgr_pwr_devices_get_current(struct gk20a *g, u32 *val);
31int pmgr_pwr_devices_get_voltage(struct gk20a *g, u32 *val);
32int pmgr_pwr_devices_get_power(struct gk20a *g, u32 *val);
33
34#endif
diff --git a/drivers/gpu/nvgpu/pmgr/pmgrpmu.c b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
new file mode 100644
index 00000000..ea070060
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pmgrpmu.c
@@ -0,0 +1,524 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "pwrdev.h"
16#include "include/bios.h"
17#include "boardobj/boardobjgrp.h"
18#include "boardobj/boardobjgrp_e32.h"
19#include "pmuif/gpmuifboardobj.h"
20#include "pmuif/gpmuifpmgr.h"
21#include "gm206/bios_gm206.h"
22#include "gk20a/pmu_gk20a.h"
23#include "pmgrpmu.h"
24
25struct pmgr_pmucmdhandler_params {
26 u32 success;
27};
28
29static void pmgr_pmucmdhandler(struct gk20a *g, struct pmu_msg *msg,
30 void *param, u32 handle, u32 status)
31{
32 struct pmgr_pmucmdhandler_params *phandlerparams =
33 (struct pmgr_pmucmdhandler_params *)param;
34
35 if ((msg->msg.pmgr.msg_type != NV_PMU_PMGR_MSG_ID_SET_OBJECT) &&
36 (msg->msg.pmgr.msg_type != NV_PMU_PMGR_MSG_ID_QUERY) &&
37 (msg->msg.pmgr.msg_type != NV_PMU_PMGR_MSG_ID_LOAD)) {
38 gk20a_err(dev_from_gk20a(g),
39 "unknow msg %x",
40 msg->msg.pmgr.msg_type);
41 return;
42 }
43
44 if (msg->msg.pmgr.msg_type == NV_PMU_PMGR_MSG_ID_SET_OBJECT) {
45 if ((msg->msg.pmgr.set_object.b_success != 1) ||
46 (msg->msg.pmgr.set_object.flcnstatus != 0) ) {
47 gk20a_err(dev_from_gk20a(g),
48 "pmgr msg failed %x %x %x %x",
49 msg->msg.pmgr.set_object.msg_type,
50 msg->msg.pmgr.set_object.b_success,
51 msg->msg.pmgr.set_object.flcnstatus,
52 msg->msg.pmgr.set_object.object_type);
53 return;
54 }
55 } else if (msg->msg.pmgr.msg_type == NV_PMU_PMGR_MSG_ID_QUERY) {
56 if ((msg->msg.pmgr.query.b_success != 1) ||
57 (msg->msg.pmgr.query.flcnstatus != 0) ) {
58 gk20a_err(dev_from_gk20a(g),
59 "pmgr msg failed %x %x %x %x",
60 msg->msg.pmgr.query.msg_type,
61 msg->msg.pmgr.query.b_success,
62 msg->msg.pmgr.query.flcnstatus,
63 msg->msg.pmgr.query.cmd_type);
64 return;
65 }
66 } else if (msg->msg.pmgr.msg_type == NV_PMU_PMGR_MSG_ID_LOAD) {
67 if ((msg->msg.pmgr.query.b_success != 1) ||
68 (msg->msg.pmgr.query.flcnstatus != 0) ) {
69 gk20a_err(dev_from_gk20a(g),
70 "pmgr msg failed %x %x %x",
71 msg->msg.pmgr.load.msg_type,
72 msg->msg.pmgr.load.b_success,
73 msg->msg.pmgr.load.flcnstatus);
74 return;
75 }
76 }
77
78 phandlerparams->success = 1;
79}
80
81static u32 pmgr_pmu_set_object(struct gk20a *g,
82 u8 type,
83 u16 dmem_size,
84 u16 fb_size,
85 void *pobj)
86{
87 struct pmu_cmd cmd = { {0} };
88 struct pmu_payload payload = { {0} };
89 struct nv_pmu_pmgr_cmd_set_object *pcmd;
90 u32 status;
91 u32 seqdesc;
92 struct pmgr_pmucmdhandler_params handlerparams = {0};
93
94 cmd.hdr.unit_id = PMU_UNIT_PMGR;
95 cmd.hdr.size = (u32)sizeof(struct nv_pmu_pmgr_cmd_set_object) +
96 (u32)sizeof(struct pmu_hdr);;
97
98 pcmd = &cmd.cmd.pmgr.set_object;
99 pcmd->cmd_type = NV_PMU_PMGR_CMD_ID_SET_OBJECT;
100 pcmd->object_type = type;
101
102 payload.in.buf = pobj;
103 payload.in.size = dmem_size;
104 payload.in.fb_size = fb_size;
105 payload.in.offset = NV_PMU_PMGR_SET_OBJECT_ALLOC_OFFSET;
106
107 /* Setup the handler params to communicate back results.*/
108 handlerparams.success = 0;
109
110 status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload,
111 PMU_COMMAND_QUEUE_LPQ,
112 pmgr_pmucmdhandler,
113 (void *)&handlerparams,
114 &seqdesc, ~0);
115 if (status) {
116 gk20a_err(dev_from_gk20a(g),
117 "unable to post pmgr cmd for unit %x cmd id %x obj type %x",
118 cmd.hdr.unit_id, pcmd->cmd_type, pcmd->object_type);
119 goto exit;
120 }
121
122 pmu_wait_message_cond(&g->pmu,
123 gk20a_get_gr_idle_timeout(g),
124 &handlerparams.success, 1);
125
126 if (handlerparams.success == 0) {
127 gk20a_err(dev_from_gk20a(g), "could not process cmd\n");
128 status = -ETIMEDOUT;
129 goto exit;
130 }
131
132exit:
133 return status;
134}
135
136static u32 pmgr_send_i2c_device_topology_to_pmu(struct gk20a *g)
137{
138 struct nv_pmu_pmgr_i2c_device_desc_table i2c_desc_table;
139 u32 status = 0;
140
141 /* INA3221 I2C device info */
142 i2c_desc_table.dev_mask = 0x01;
143
144 /* INA3221 */
145 i2c_desc_table.devices[0].super.type = 0x4E;
146
147 i2c_desc_table.devices[0].dcb_index = 0;
148 i2c_desc_table.devices[0].i2c_address = 0x84;
149 i2c_desc_table.devices[0].i2c_flags = 0xC2F;
150 i2c_desc_table.devices[0].i2c_port = 0x2;
151
152 /* Pass the table down the PMU as an object */
153 status = pmgr_pmu_set_object(
154 g,
155 NV_PMU_PMGR_OBJECT_I2C_DEVICE_DESC_TABLE,
156 (u16)sizeof(struct nv_pmu_pmgr_i2c_device_desc_table),
157 PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED,
158 &i2c_desc_table);
159
160 if (status)
161 gk20a_err(dev_from_gk20a(g),
162 "pmgr_pmu_set_object failed %x",
163 status);
164
165 return status;
166}
167
168static u32 pmgr_send_pwr_device_topology_to_pmu(struct gk20a *g)
169{
170 struct nv_pmu_pmgr_pwr_device_desc_table pwr_desc_table;
171 struct nv_pmu_pmgr_pwr_device_desc_table_header *ppwr_desc_header;
172 u32 status = 0;
173
174 /* Set the BA-device-independent HW information */
175 ppwr_desc_header = &(pwr_desc_table.hdr.data);
176 ppwr_desc_header->ba_info.b_initialized_and_used = false;
177
178 /* populate the table */
179 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&ppwr_desc_header->super,
180 g->pmgr_pmu.pmgr_deviceobjs.super.super.objmask);
181
182 status = boardobjgrp_pmudatainit_legacy(g,
183 &g->pmgr_pmu.pmgr_deviceobjs.super.super,
184 (struct nv_pmu_boardobjgrp_super *)&pwr_desc_table);
185
186 if (status) {
187 gk20a_err(dev_from_gk20a(g),
188 "boardobjgrp_pmudatainit_legacy failed %x",
189 status);
190 goto exit;
191 }
192
193 /* Pass the table down the PMU as an object */
194 status = pmgr_pmu_set_object(
195 g,
196 NV_PMU_PMGR_OBJECT_PWR_DEVICE_DESC_TABLE,
197 (u16)sizeof(
198 union nv_pmu_pmgr_pwr_device_dmem_size),
199 (u16)sizeof(struct nv_pmu_pmgr_pwr_device_desc_table),
200 &pwr_desc_table);
201
202 if (status)
203 gk20a_err(dev_from_gk20a(g),
204 "pmgr_pmu_set_object failed %x",
205 status);
206
207exit:
208 return status;
209}
210
211static u32 pmgr_send_pwr_mointer_to_pmu(struct gk20a *g)
212{
213 struct nv_pmu_pmgr_pwr_monitor_pack pwr_monitor_pack;
214 struct nv_pmu_pmgr_pwr_channel_header *pwr_channel_hdr;
215 struct nv_pmu_pmgr_pwr_chrelationship_header *pwr_chrelationship_header;
216 u32 max_dmem_size;
217 u32 status = 0;
218
219 /* Copy all the global settings from the RM copy */
220 pwr_channel_hdr = &(pwr_monitor_pack.channels.hdr.data);
221 pwr_monitor_pack = g->pmgr_pmu.pmgr_monitorobjs.pmu_data;
222
223 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&pwr_channel_hdr->super,
224 g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super.objmask);
225
226 /* Copy in each channel */
227 status = boardobjgrp_pmudatainit_legacy(g,
228 &g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super,
229 (struct nv_pmu_boardobjgrp_super *)&(pwr_monitor_pack.channels));
230
231 if (status) {
232 gk20a_err(dev_from_gk20a(g),
233 "boardobjgrp_pmudatainit_legacy failed %x",
234 status);
235 goto exit;
236 }
237
238 /* Copy in each channel relationship */
239 pwr_chrelationship_header = &(pwr_monitor_pack.ch_rels.hdr.data);
240
241 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)&pwr_chrelationship_header->super,
242 g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super.objmask);
243
244 pwr_channel_hdr->physical_channel_mask = g->pmgr_pmu.pmgr_monitorobjs.physical_channel_mask;
245 pwr_channel_hdr->type = NV_PMU_PMGR_PWR_MONITOR_TYPE_NO_POLLING;
246
247 status = boardobjgrp_pmudatainit_legacy(g,
248 &g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super,
249 (struct nv_pmu_boardobjgrp_super *)&(pwr_monitor_pack.ch_rels));
250
251 if (status) {
252 gk20a_err(dev_from_gk20a(g),
253 "boardobjgrp_pmudatainit_legacy failed %x",
254 status);
255 goto exit;
256 }
257
258 /* Calculate the max Dmem buffer size */
259 max_dmem_size = sizeof(union nv_pmu_pmgr_pwr_monitor_dmem_size);
260
261 /* Pass the table down the PMU as an object */
262 status = pmgr_pmu_set_object(
263 g,
264 NV_PMU_PMGR_OBJECT_PWR_MONITOR,
265 (u16)max_dmem_size,
266 (u16)sizeof(struct nv_pmu_pmgr_pwr_monitor_pack),
267 &pwr_monitor_pack);
268
269 if (status)
270 gk20a_err(dev_from_gk20a(g),
271 "pmgr_pmu_set_object failed %x",
272 status);
273
274exit:
275 return status;
276}
277
278u32 pmgr_send_pwr_policy_to_pmu(struct gk20a *g)
279{
280 struct nv_pmu_pmgr_pwr_policy_pack *ppwrpack = NULL;
281 struct pwr_policy *ppolicy = NULL;
282 u32 status = 0;
283 u8 indx;
284 u32 max_dmem_size;
285
286 ppwrpack = kzalloc(sizeof(struct nv_pmu_pmgr_pwr_policy_pack), GFP_KERNEL);
287 if (!ppwrpack) {
288 gk20a_err(dev_from_gk20a(g),
289 "pwr policy alloc failed %x",
290 status);
291 status = -ENOMEM;
292 goto exit;
293 }
294
295 ppwrpack->policies.hdr.data.version = g->pmgr_pmu.pmgr_policyobjs.version;
296 ppwrpack->policies.hdr.data.b_enabled = g->pmgr_pmu.pmgr_policyobjs.b_enabled;
297
298 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)
299 &ppwrpack->policies.hdr.data.super,
300 g->pmgr_pmu.pmgr_policyobjs.pwr_policies.super.objmask);
301
302 memset(&ppwrpack->policies.hdr.data.reserved_pmu_policy_mask,
303 0,
304 sizeof(ppwrpack->policies.hdr.data.reserved_pmu_policy_mask));
305
306 ppwrpack->policies.hdr.data.base_sample_period =
307 g->pmgr_pmu.pmgr_policyobjs.base_sample_period;
308 ppwrpack->policies.hdr.data.min_client_sample_period =
309 g->pmgr_pmu.pmgr_policyobjs.min_client_sample_period;
310 ppwrpack->policies.hdr.data.low_sampling_mult =
311 g->pmgr_pmu.pmgr_policyobjs.low_sampling_mult;
312
313 memcpy(&ppwrpack->policies.hdr.data.global_ceiling,
314 &g->pmgr_pmu.pmgr_policyobjs.global_ceiling,
315 sizeof(struct nv_pmu_perf_domain_group_limits));
316
317 memcpy(&ppwrpack->policies.hdr.data.semantic_policy_tbl,
318 &g->pmgr_pmu.pmgr_policyobjs.policy_idxs,
319 sizeof(g->pmgr_pmu.pmgr_policyobjs.policy_idxs));
320
321 BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK(32, indx,
322 ppwrpack->policies.hdr.data.super.obj_mask.super.data[0]) {
323 ppolicy = PMGR_GET_PWR_POLICY(g, indx);
324
325 status = ((struct boardobj *)ppolicy)->pmudatainit(g, (struct boardobj *)ppolicy,
326 (struct nv_pmu_boardobj *)&(ppwrpack->policies.policies[indx].data));
327 if (status) {
328 gk20a_err(dev_from_gk20a(g),
329 "pmudatainit failed %x indx %x",
330 status, indx);
331 status = -ENOMEM;
332 goto exit;
333 }
334 }
335 BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK_END;
336
337 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)
338 &ppwrpack->policy_rels.hdr.data.super,
339 g->pmgr_pmu.pmgr_policyobjs.pwr_policy_rels.super.objmask);
340
341 boardobjgrpe32hdrset((struct nv_pmu_boardobjgrp *)
342 &ppwrpack->violations.hdr.data.super,
343 g->pmgr_pmu.pmgr_policyobjs.pwr_violations.super.objmask);
344
345 max_dmem_size = sizeof(union nv_pmu_pmgr_pwr_policy_dmem_size);
346
347 /* Pass the table down the PMU as an object */
348 status = pmgr_pmu_set_object(
349 g,
350 NV_PMU_PMGR_OBJECT_PWR_POLICY,
351 (u16)max_dmem_size,
352 (u16)sizeof(struct nv_pmu_pmgr_pwr_policy_pack),
353 ppwrpack);
354
355 if (status)
356 gk20a_err(dev_from_gk20a(g),
357 "pmgr_pmu_set_object failed %x",
358 status);
359
360exit:
361 if (ppwrpack) {
362 kfree(ppwrpack);
363 }
364
365 return status;
366}
367
368u32 pmgr_pmu_pwr_devices_query_blocking(
369 struct gk20a *g,
370 u32 pwr_dev_mask,
371 struct nv_pmu_pmgr_pwr_devices_query_payload *ppayload)
372{
373 struct pmu_cmd cmd = { {0} };
374 struct pmu_payload payload = { {0} };
375 struct nv_pmu_pmgr_cmd_pwr_devices_query *pcmd;
376 u32 status;
377 u32 seqdesc;
378 struct pmgr_pmucmdhandler_params handlerparams = {0};
379
380 cmd.hdr.unit_id = PMU_UNIT_PMGR;
381 cmd.hdr.size = (u32)sizeof(struct nv_pmu_pmgr_cmd_pwr_devices_query) +
382 (u32)sizeof(struct pmu_hdr);
383
384 pcmd = &cmd.cmd.pmgr.pwr_dev_query;
385 pcmd->cmd_type = NV_PMU_PMGR_CMD_ID_PWR_DEVICES_QUERY;
386 pcmd->dev_mask = pwr_dev_mask;
387
388 payload.out.buf = ppayload;
389 payload.out.size = sizeof(struct nv_pmu_pmgr_pwr_devices_query_payload);
390 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
391 payload.out.offset = NV_PMU_PMGR_PWR_DEVICES_QUERY_ALLOC_OFFSET;
392
393 /* Setup the handler params to communicate back results.*/
394 handlerparams.success = 0;
395
396 status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload,
397 PMU_COMMAND_QUEUE_LPQ,
398 pmgr_pmucmdhandler,
399 (void *)&handlerparams,
400 &seqdesc, ~0);
401 if (status) {
402 gk20a_err(dev_from_gk20a(g),
403 "unable to post pmgr query cmd for unit %x cmd id %x dev mask %x",
404 cmd.hdr.unit_id, pcmd->cmd_type, pcmd->dev_mask);
405 goto exit;
406 }
407
408 pmu_wait_message_cond(&g->pmu,
409 gk20a_get_gr_idle_timeout(g),
410 &handlerparams.success, 1);
411
412 if (handlerparams.success == 0) {
413 gk20a_err(dev_from_gk20a(g), "could not process cmd\n");
414 status = -ETIMEDOUT;
415 goto exit;
416 }
417
418exit:
419 return status;
420}
421
422static u32 pmgr_pmu_load_blocking(struct gk20a *g)
423{
424 struct pmu_cmd cmd = { {0} };
425 struct nv_pmu_pmgr_cmd_load *pcmd;
426 u32 status;
427 u32 seqdesc;
428 struct pmgr_pmucmdhandler_params handlerparams = {0};
429
430 cmd.hdr.unit_id = PMU_UNIT_PMGR;
431 cmd.hdr.size = (u32)sizeof(struct nv_pmu_pmgr_cmd_load) +
432 (u32)sizeof(struct pmu_hdr);
433
434 pcmd = &cmd.cmd.pmgr.load;
435 pcmd->cmd_type = NV_PMU_PMGR_CMD_ID_LOAD;
436
437 /* Setup the handler params to communicate back results.*/
438 handlerparams.success = 0;
439
440 status = gk20a_pmu_cmd_post(g, &cmd, NULL, NULL,
441 PMU_COMMAND_QUEUE_LPQ,
442 pmgr_pmucmdhandler,
443 (void *)&handlerparams,
444 &seqdesc, ~0);
445 if (status) {
446 gk20a_err(dev_from_gk20a(g),
447 "unable to post pmgr load cmd for unit %x cmd id %x",
448 cmd.hdr.unit_id, pcmd->cmd_type);
449 goto exit;
450 }
451
452 pmu_wait_message_cond(&g->pmu,
453 gk20a_get_gr_idle_timeout(g),
454 &handlerparams.success, 1);
455
456 if (handlerparams.success == 0) {
457 gk20a_err(dev_from_gk20a(g), "could not process cmd\n");
458 status = -ETIMEDOUT;
459 goto exit;
460 }
461
462exit:
463 return status;
464}
465
466u32 pmgr_send_pmgr_tables_to_pmu(struct gk20a *g)
467{
468 u32 status = 0;
469
470 status = pmgr_send_i2c_device_topology_to_pmu(g);
471
472 if (status) {
473 gk20a_err(dev_from_gk20a(g),
474 "pmgr_send_i2c_device_topology_to_pmu failed %x",
475 status);
476 goto exit;
477 }
478
479 if (!BOARDOBJGRP_IS_EMPTY(&g->pmgr_pmu.pmgr_deviceobjs.super.super)) {
480 status = pmgr_send_pwr_device_topology_to_pmu(g);
481 if (status) {
482 gk20a_err(dev_from_gk20a(g),
483 "pmgr_send_pwr_device_topology_to_pmu failed %x",
484 status);
485 goto exit;
486 }
487 }
488
489 if (!(BOARDOBJGRP_IS_EMPTY(
490 &g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super)) ||
491 !(BOARDOBJGRP_IS_EMPTY(
492 &g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super))) {
493 status = pmgr_send_pwr_mointer_to_pmu(g);
494 if (status) {
495 gk20a_err(dev_from_gk20a(g),
496 "pmgr_send_pwr_mointer_to_pmu failed %x", status);
497 goto exit;
498 }
499 }
500
501 if (!(BOARDOBJGRP_IS_EMPTY(
502 &g->pmgr_pmu.pmgr_policyobjs.pwr_policies.super)) ||
503 !(BOARDOBJGRP_IS_EMPTY(
504 &g->pmgr_pmu.pmgr_policyobjs.pwr_policy_rels.super)) ||
505 !(BOARDOBJGRP_IS_EMPTY(
506 &g->pmgr_pmu.pmgr_policyobjs.pwr_violations.super))) {
507 status = pmgr_send_pwr_policy_to_pmu(g);
508 if (status) {
509 gk20a_err(dev_from_gk20a(g),
510 "pmgr_send_pwr_policy_to_pmu failed %x", status);
511 goto exit;
512 }
513 }
514
515 status = pmgr_pmu_load_blocking(g);
516 if (status) {
517 gk20a_err(dev_from_gk20a(g),
518 "pmgr_send_pwr_mointer_to_pmu failed %x", status);
519 goto exit;
520 }
521
522exit:
523 return status;
524}
diff --git a/drivers/gpu/nvgpu/pmgr/pmgrpmu.h b/drivers/gpu/nvgpu/pmgr/pmgrpmu.h
new file mode 100644
index 00000000..6b48396c
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pmgrpmu.h
@@ -0,0 +1,29 @@
1/*
2 * general power device control structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _PMGRPMU_H_
16#define _PMGRPMU_H_
17
18#include "gk20a/gk20a.h"
19#include "pwrdev.h"
20#include "pwrmonitor.h"
21
22u32 pmgr_send_pmgr_tables_to_pmu(struct gk20a *g);
23
24u32 pmgr_pmu_pwr_devices_query_blocking(
25 struct gk20a *g,
26 u32 pwr_dev_mask,
27 struct nv_pmu_pmgr_pwr_devices_query_payload *ppayload);
28
29#endif
diff --git a/drivers/gpu/nvgpu/pmgr/pwrdev.c b/drivers/gpu/nvgpu/pmgr/pwrdev.c
new file mode 100644
index 00000000..03e2eb34
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pwrdev.c
@@ -0,0 +1,310 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "pwrdev.h"
16#include "include/bios.h"
17#include "boardobj/boardobjgrp.h"
18#include "boardobj/boardobjgrp_e32.h"
19#include "pmuif/gpmuifboardobj.h"
20#include "pmuif/gpmuifpmgr.h"
21#include "gm206/bios_gm206.h"
22#include "gk20a/pmu_gk20a.h"
23
24static u32 _pwr_device_pmudata_instget(struct gk20a *g,
25 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
26 struct nv_pmu_boardobj **ppboardobjpmudata,
27 u8 idx)
28{
29 struct nv_pmu_pmgr_pwr_device_desc_table *ppmgrdevice =
30 (struct nv_pmu_pmgr_pwr_device_desc_table *)pmuboardobjgrp;
31
32 gk20a_dbg_info("");
33
34 /*check whether pmuboardobjgrp has a valid boardobj in index*/
35 if (((u32)BIT(idx) &
36 ppmgrdevice->hdr.data.super.obj_mask.super.data[0]) == 0)
37 return -EINVAL;
38
39 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
40 &ppmgrdevice->devices[idx].data.board_obj;
41
42 gk20a_dbg_info(" Done");
43
44 return 0;
45}
46
47static u32 _pwr_domains_pmudatainit_ina3221(struct gk20a *g,
48 struct boardobj *board_obj_ptr,
49 struct nv_pmu_boardobj *ppmudata)
50{
51 struct nv_pmu_pmgr_pwr_device_desc_ina3221 *ina3221_desc;
52 struct pwr_device_ina3221 *ina3221;
53 u32 status = 0;
54 u32 indx;
55
56 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
57 if (status) {
58 gk20a_err(dev_from_gk20a(g),
59 "error updating pmu boardobjgrp for pwr domain 0x%x",
60 status);
61 goto done;
62 }
63
64 ina3221 = (struct pwr_device_ina3221 *)board_obj_ptr;
65 ina3221_desc = (struct nv_pmu_pmgr_pwr_device_desc_ina3221 *) ppmudata;
66
67 ina3221_desc->super.power_corr_factor = ina3221->super.power_corr_factor;
68 ina3221_desc->i2c_dev_idx = ina3221->super.i2c_dev_idx;
69 ina3221_desc->configuration = ina3221->configuration;
70 ina3221_desc->mask_enable = ina3221->mask_enable;
71 /* configure NV_PMU_THERM_EVENT_EXT_OVERT */
72 ina3221_desc->event_mask = (1 << 0);
73 ina3221_desc->curr_correct_m = ina3221->curr_correct_m;
74 ina3221_desc->curr_correct_b = ina3221->curr_correct_b;
75
76 for (indx = 0; indx < NV_PMU_PMGR_PWR_DEVICE_INA3221_CH_NUM; indx++) {
77 ina3221_desc->r_shuntm_ohm[indx] = ina3221->r_shuntm_ohm[indx];
78 }
79
80done:
81 return status;
82}
83
84static struct boardobj *construct_pwr_device(struct gk20a *g,
85 void *pargs, u16 pargs_size, u8 type)
86{
87 struct boardobj *board_obj_ptr = NULL;
88 u32 status;
89 u32 indx;
90 struct pwr_device_ina3221 *pwrdev;
91 struct pwr_device_ina3221 *ina3221 = (struct pwr_device_ina3221*)pargs;
92
93 status = boardobj_construct_super(g, &board_obj_ptr,
94 pargs_size, pargs);
95 if (status)
96 return NULL;
97
98 pwrdev = (struct pwr_device_ina3221*)board_obj_ptr;
99
100 /* Set Super class interfaces */
101 board_obj_ptr->pmudatainit = _pwr_domains_pmudatainit_ina3221;
102 pwrdev->super.power_rail = ina3221->super.power_rail;
103 pwrdev->super.i2c_dev_idx = ina3221->super.i2c_dev_idx;
104 pwrdev->super.power_corr_factor = (1 << 12);
105 pwrdev->super.bIs_inforom_config = false;
106
107 /* Set INA3221-specific information */
108 pwrdev->configuration = ina3221->configuration;
109 pwrdev->mask_enable = ina3221->mask_enable;
110 pwrdev->gpio_function = ina3221->gpio_function;
111 pwrdev->curr_correct_m = ina3221->curr_correct_m;
112 pwrdev->curr_correct_b = ina3221->curr_correct_b;
113
114 for (indx = 0; indx < NV_PMU_PMGR_PWR_DEVICE_INA3221_CH_NUM; indx++) {
115 pwrdev->r_shuntm_ohm[indx] = ina3221->r_shuntm_ohm[indx];
116 }
117
118 gk20a_dbg_info(" Done");
119
120 return board_obj_ptr;
121}
122
123static u32 devinit_get_pwr_device_table(struct gk20a *g,
124 struct pwr_devices *ppwrdeviceobjs)
125{
126 u32 status = 0;
127 u8 *pwr_device_table_ptr = NULL;
128 u8 *curr_pwr_device_table_ptr = NULL;
129 struct boardobj *boardobj;
130 struct pwr_sensors_2x_header pwr_sensor_table_header = { 0 };
131 struct pwr_sensors_2x_entry pwr_sensor_table_entry = { 0 };
132 u32 index;
133 u32 obj_index = 0;
134 u16 pwr_device_size;
135 union {
136 struct boardobj boardobj;
137 struct pwr_device pwrdev;
138 struct pwr_device_ina3221 ina3221;
139 } pwr_device_data;
140
141 gk20a_dbg_info("");
142
143 if (g->ops.bios.get_perf_table_ptrs != NULL) {
144 pwr_device_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
145 g->bios.perf_token, POWER_SENSORS_TABLE);
146 if (pwr_device_table_ptr == NULL) {
147 status = -EINVAL;
148 goto done;
149 }
150 }
151
152 memcpy(&pwr_sensor_table_header, pwr_device_table_ptr,
153 VBIOS_POWER_SENSORS_2X_HEADER_SIZE_08);
154
155 if (pwr_sensor_table_header.version !=
156 VBIOS_POWER_SENSORS_VERSION_2X) {
157 status = -EINVAL;
158 goto done;
159 }
160
161 if (pwr_sensor_table_header.header_size <
162 VBIOS_POWER_SENSORS_2X_HEADER_SIZE_08) {
163 status = -EINVAL;
164 goto done;
165 }
166
167 if (pwr_sensor_table_header.table_entry_size !=
168 VBIOS_POWER_SENSORS_2X_ENTRY_SIZE_15) {
169 status = -EINVAL;
170 goto done;
171 }
172
173 curr_pwr_device_table_ptr = (pwr_device_table_ptr +
174 VBIOS_POWER_SENSORS_2X_HEADER_SIZE_08);
175
176 for (index = 0; index < pwr_sensor_table_header.num_table_entries; index++) {
177 bool use_fxp8_8 = false;
178 u8 i2c_dev_idx;
179 u8 device_type;
180
181 curr_pwr_device_table_ptr += (pwr_sensor_table_header.table_entry_size * index);
182
183 pwr_sensor_table_entry.flags0 = *curr_pwr_device_table_ptr;
184
185 memcpy(&pwr_sensor_table_entry.class_param0,
186 (curr_pwr_device_table_ptr + 1),
187 (VBIOS_POWER_SENSORS_2X_ENTRY_SIZE_15 - 1));
188
189 device_type = (u8)BIOS_GET_FIELD(
190 pwr_sensor_table_entry.flags0,
191 NV_VBIOS_POWER_SENSORS_2X_ENTRY_FLAGS0_CLASS);
192
193 if (device_type == NV_VBIOS_POWER_SENSORS_2X_ENTRY_FLAGS0_CLASS_I2C) {
194 i2c_dev_idx = (u8)BIOS_GET_FIELD(
195 pwr_sensor_table_entry.class_param0,
196 NV_VBIOS_POWER_SENSORS_2X_ENTRY_CLASS_PARAM0_I2C_INDEX);
197 use_fxp8_8 = (u8)BIOS_GET_FIELD(
198 pwr_sensor_table_entry.class_param0,
199 NV_VBIOS_POWER_SENSORS_2X_ENTRY_CLASS_PARAM0_I2C_USE_FXP8_8);
200
201 pwr_device_data.ina3221.super.i2c_dev_idx = i2c_dev_idx;
202 pwr_device_data.ina3221.r_shuntm_ohm[0].use_fxp8_8 = use_fxp8_8;
203 pwr_device_data.ina3221.r_shuntm_ohm[1].use_fxp8_8 = use_fxp8_8;
204 pwr_device_data.ina3221.r_shuntm_ohm[2].use_fxp8_8 = use_fxp8_8;
205 pwr_device_data.ina3221.r_shuntm_ohm[0].rshunt_value =
206 (u16)BIOS_GET_FIELD(
207 pwr_sensor_table_entry.sensor_param0,
208 NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM0_INA3221_RSHUNT0_MOHM);
209
210 pwr_device_data.ina3221.r_shuntm_ohm[1].rshunt_value =
211 (u16)BIOS_GET_FIELD(
212 pwr_sensor_table_entry.sensor_param0,
213 NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM0_INA3221_RSHUNT1_MOHM);
214
215 pwr_device_data.ina3221.r_shuntm_ohm[2].rshunt_value =
216 (u16)BIOS_GET_FIELD(
217 pwr_sensor_table_entry.sensor_param1,
218 NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM1_INA3221_RSHUNT2_MOHM);
219 pwr_device_data.ina3221.configuration =
220 (u16)BIOS_GET_FIELD(
221 pwr_sensor_table_entry.sensor_param1,
222 NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM1_INA3221_CONFIGURATION);
223
224 pwr_device_data.ina3221.mask_enable =
225 (u16)BIOS_GET_FIELD(
226 pwr_sensor_table_entry.sensor_param2,
227 NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM2_INA3221_MASKENABLE);
228
229 pwr_device_data.ina3221.gpio_function =
230 (u8)BIOS_GET_FIELD(
231 pwr_sensor_table_entry.sensor_param2,
232 NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM2_INA3221_GPIOFUNCTION);
233
234 pwr_device_data.ina3221.curr_correct_m =
235 (u16)BIOS_GET_FIELD(
236 pwr_sensor_table_entry.sensor_param3,
237 NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM3_INA3221_CURR_CORRECT_M);
238
239 pwr_device_data.ina3221.curr_correct_b =
240 (u16)BIOS_GET_FIELD(
241 pwr_sensor_table_entry.sensor_param3,
242 NV_VBIOS_POWER_SENSORS_2X_ENTRY_SENSOR_PARAM3_INA3221_CURR_CORRECT_B);
243
244 if (!pwr_device_data.ina3221.curr_correct_m) {
245 pwr_device_data.ina3221.curr_correct_m = (1 << 12);
246 }
247 pwr_device_size = sizeof(struct pwr_device_ina3221);
248 } else
249 continue;
250
251 pwr_device_data.boardobj.type = CTRL_PMGR_PWR_DEVICE_TYPE_INA3221;
252 pwr_device_data.pwrdev.power_rail = (u8)0;
253
254 boardobj = construct_pwr_device(g, &pwr_device_data,
255 pwr_device_size, pwr_device_data.boardobj.type);
256
257 if (!boardobj) {
258 gk20a_err(dev_from_gk20a(g),
259 "unable to create pwr device for %d type %d", index, pwr_device_data.boardobj.type);
260 status = -EINVAL;
261 goto done;
262 }
263
264 status = boardobjgrp_objinsert(&ppwrdeviceobjs->super.super,
265 boardobj, obj_index);
266
267 if (status) {
268 gk20a_err(dev_from_gk20a(g),
269 "unable to insert pwr device boardobj for %d", index);
270 status = -EINVAL;
271 goto done;
272 }
273
274 ++obj_index;
275 }
276
277done:
278 gk20a_dbg_info(" done status %x", status);
279 return status;
280}
281
282u32 pmgr_device_sw_setup(struct gk20a *g)
283{
284 u32 status;
285 struct boardobjgrp *pboardobjgrp = NULL;
286 struct pwr_devices *ppwrdeviceobjs;
287
288 /* Construct the Super Class and override the Interfaces */
289 status = boardobjgrpconstruct_e32(&g->pmgr_pmu.pmgr_deviceobjs.super);
290 if (status) {
291 gk20a_err(dev_from_gk20a(g),
292 "error creating boardobjgrp for pmgr devices, status - 0x%x",
293 status);
294 goto done;
295 }
296
297 pboardobjgrp = &g->pmgr_pmu.pmgr_deviceobjs.super.super;
298 ppwrdeviceobjs = &(g->pmgr_pmu.pmgr_deviceobjs);
299
300 /* Override the Interfaces */
301 pboardobjgrp->pmudatainstget = _pwr_device_pmudata_instget;
302
303 status = devinit_get_pwr_device_table(g, ppwrdeviceobjs);
304 if (status)
305 goto done;
306
307done:
308 gk20a_dbg_info(" done status %x", status);
309 return status;
310}
diff --git a/drivers/gpu/nvgpu/pmgr/pwrdev.h b/drivers/gpu/nvgpu/pmgr/pwrdev.h
new file mode 100644
index 00000000..b8592a18
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pwrdev.h
@@ -0,0 +1,51 @@
1/*
2 * general power device structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _PWRDEV_H_
16#define _PWRDEV_H_
17
18#include "boardobj/boardobj.h"
19#include "pmuif/gpmuifpmgr.h"
20#include "ctrl/ctrlpmgr.h"
21
22#define PWRDEV_I2CDEV_DEVICE_INDEX_NONE (0xFF)
23
24#define PWR_DEVICE_PROV_NUM_DEFAULT 1
25
26struct pwr_device {
27 struct boardobj super;
28 u8 power_rail;
29 u8 i2c_dev_idx;
30 bool bIs_inforom_config;
31 u32 power_corr_factor;
32};
33
34struct pwr_devices {
35 struct boardobjgrp_e32 super;
36};
37
38struct pwr_device_ina3221 {
39 struct pwr_device super;
40 struct ctrl_pmgr_pwr_device_info_rshunt
41 r_shuntm_ohm[NV_PMU_PMGR_PWR_DEVICE_INA3221_CH_NUM];
42 u16 configuration;
43 u16 mask_enable;
44 u8 gpio_function;
45 u16 curr_correct_m;
46 s16 curr_correct_b;
47} ;
48
49u32 pmgr_device_sw_setup(struct gk20a *g);
50
51#endif
diff --git a/drivers/gpu/nvgpu/pmgr/pwrmonitor.c b/drivers/gpu/nvgpu/pmgr/pwrmonitor.c
new file mode 100644
index 00000000..c28751fd
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pwrmonitor.c
@@ -0,0 +1,365 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "pwrdev.h"
16#include "include/bios.h"
17#include "boardobj/boardobjgrp.h"
18#include "boardobj/boardobjgrp_e32.h"
19#include "pmuif/gpmuifboardobj.h"
20#include "pmuif/gpmuifpmgr.h"
21#include "gm206/bios_gm206.h"
22#include "gk20a/pmu_gk20a.h"
23
24static u32 _pwr_channel_pmudata_instget(struct gk20a *g,
25 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
26 struct nv_pmu_boardobj **ppboardobjpmudata,
27 u8 idx)
28{
29 struct nv_pmu_pmgr_pwr_channel_desc *ppmgrchannel =
30 (struct nv_pmu_pmgr_pwr_channel_desc *)pmuboardobjgrp;
31
32 gk20a_dbg_info("");
33
34 /*check whether pmuboardobjgrp has a valid boardobj in index*/
35 if (((u32)BIT(idx) &
36 ppmgrchannel->hdr.data.super.obj_mask.super.data[0]) == 0)
37 return -EINVAL;
38
39 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
40 &ppmgrchannel->channels[idx].data.board_obj;
41
42 /* handle Global/common data here as we need index */
43 ppmgrchannel->channels[idx].data.pwr_channel.ch_idx = idx;
44
45 gk20a_dbg_info(" Done");
46
47 return 0;
48}
49
50static u32 _pwr_channel_rels_pmudata_instget(struct gk20a *g,
51 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
52 struct nv_pmu_boardobj **ppboardobjpmudata,
53 u8 idx)
54{
55 struct nv_pmu_pmgr_pwr_chrelationship_desc *ppmgrchrels =
56 (struct nv_pmu_pmgr_pwr_chrelationship_desc *)pmuboardobjgrp;
57
58 gk20a_dbg_info("");
59
60 /*check whether pmuboardobjgrp has a valid boardobj in index*/
61 if (((u32)BIT(idx) &
62 ppmgrchrels->hdr.data.super.obj_mask.super.data[0]) == 0)
63 return -EINVAL;
64
65 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
66 &ppmgrchrels->ch_rels[idx].data.board_obj;
67
68 gk20a_dbg_info(" Done");
69
70 return 0;
71}
72
73static u32 _pwr_channel_state_init(struct gk20a *g)
74{
75 u8 indx = 0;
76 struct pwr_channel *pchannel;
77 u32 objmask =
78 g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super.objmask;
79
80 /* Initialize each PWR_CHANNEL's dependent channel mask */
81 BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK(32, indx, objmask) {
82 pchannel = PMGR_PWR_MONITOR_GET_PWR_CHANNEL(g, indx);
83 if (pchannel == NULL) {
84 gk20a_err(dev_from_gk20a(g),
85 "PMGR_PWR_MONITOR_GET_PWR_CHANNEL-failed %d", indx);
86 return -EINVAL;
87 }
88 pchannel->dependent_ch_mask =0;
89 }
90 BOARDOBJGRP_FOR_EACH_INDEX_IN_MASK_END
91
92 return 0;
93}
94
95static bool _pwr_channel_implements(struct pwr_channel *pchannel,
96 u8 type)
97{
98 return (type == BOARDOBJ_GET_TYPE(pchannel));
99}
100
101static u32 _pwr_domains_pmudatainit_sensor(struct gk20a *g,
102 struct boardobj *board_obj_ptr,
103 struct nv_pmu_boardobj *ppmudata)
104{
105 struct nv_pmu_pmgr_pwr_channel_sensor *pmu_sensor_data;
106 struct pwr_channel_sensor *sensor;
107 u32 status = 0;
108
109 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
110 if (status) {
111 gk20a_err(dev_from_gk20a(g),
112 "error updating pmu boardobjgrp for pwr sensor 0x%x",
113 status);
114 goto done;
115 }
116
117 sensor = (struct pwr_channel_sensor *)board_obj_ptr;
118 pmu_sensor_data = (struct nv_pmu_pmgr_pwr_channel_sensor *) ppmudata;
119
120 pmu_sensor_data->super.pwr_rail = sensor->super.pwr_rail;
121 pmu_sensor_data->super.volt_fixedu_v = sensor->super.volt_fixed_uv;
122 pmu_sensor_data->super.pwr_corr_slope = sensor->super.pwr_corr_slope;
123 pmu_sensor_data->super.pwr_corr_offsetm_w = sensor->super.pwr_corr_offset_mw;
124 pmu_sensor_data->super.curr_corr_slope = sensor->super.curr_corr_slope;
125 pmu_sensor_data->super.curr_corr_offsetm_a = sensor->super.curr_corr_offset_ma;
126 pmu_sensor_data->super.dependent_ch_mask = sensor->super.dependent_ch_mask;
127 pmu_sensor_data->super.ch_idx = 0;
128
129 pmu_sensor_data->pwr_dev_idx = sensor->pwr_dev_idx;
130 pmu_sensor_data->pwr_dev_prov_idx = sensor->pwr_dev_prov_idx;
131
132done:
133 return status;
134}
135
136static struct boardobj *construct_pwr_topology(struct gk20a *g,
137 void *pargs, u16 pargs_size, u8 type)
138{
139 struct boardobj *board_obj_ptr = NULL;
140 u32 status;
141 struct pwr_channel_sensor *pwrchannel;
142 struct pwr_channel_sensor *sensor = (struct pwr_channel_sensor*)pargs;
143
144 status = boardobj_construct_super(g, &board_obj_ptr,
145 pargs_size, pargs);
146 if (status)
147 return NULL;
148
149 pwrchannel = (struct pwr_channel_sensor*)board_obj_ptr;
150
151 /* Set Super class interfaces */
152 board_obj_ptr->pmudatainit = _pwr_domains_pmudatainit_sensor;
153
154 pwrchannel->super.pwr_rail = sensor->super.pwr_rail;
155 pwrchannel->super.volt_fixed_uv = sensor->super.volt_fixed_uv;
156 pwrchannel->super.pwr_corr_slope = sensor->super.pwr_corr_slope;
157 pwrchannel->super.pwr_corr_offset_mw = sensor->super.pwr_corr_offset_mw;
158 pwrchannel->super.curr_corr_slope = sensor->super.curr_corr_slope;
159 pwrchannel->super.curr_corr_offset_ma = sensor->super.curr_corr_offset_ma;
160 pwrchannel->super.dependent_ch_mask = 0;
161
162 pwrchannel->pwr_dev_idx = sensor->pwr_dev_idx;
163 pwrchannel->pwr_dev_prov_idx = sensor->pwr_dev_prov_idx;
164
165 gk20a_dbg_info(" Done");
166
167 return board_obj_ptr;
168}
169
170static u32 devinit_get_pwr_topology_table(struct gk20a *g,
171 struct pmgr_pwr_monitor *ppwrmonitorobjs)
172{
173 u32 status = 0;
174 u8 *pwr_topology_table_ptr = NULL;
175 u8 *curr_pwr_topology_table_ptr = NULL;
176 struct boardobj *boardobj;
177 struct pwr_topology_2x_header pwr_topology_table_header = { 0 };
178 struct pwr_topology_2x_entry pwr_topology_table_entry = { 0 };
179 u32 index;
180 u32 obj_index = 0;
181 u16 pwr_topology_size;
182 union {
183 struct boardobj boardobj;
184 struct pwr_channel pwrchannel;
185 struct pwr_channel_sensor sensor;
186 } pwr_topology_data;
187
188 gk20a_dbg_info("");
189
190 if (g->ops.bios.get_perf_table_ptrs != NULL) {
191 pwr_topology_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
192 g->bios.perf_token, POWER_TOPOLOGY_TABLE);
193 if (pwr_topology_table_ptr == NULL) {
194 status = -EINVAL;
195 goto done;
196 }
197 }
198
199 memcpy(&pwr_topology_table_header, pwr_topology_table_ptr,
200 VBIOS_POWER_TOPOLOGY_2X_HEADER_SIZE_06);
201
202 if (pwr_topology_table_header.version !=
203 VBIOS_POWER_TOPOLOGY_VERSION_2X) {
204 status = -EINVAL;
205 goto done;
206 }
207
208 g->pmgr_pmu.pmgr_monitorobjs.b_is_topology_tbl_ver_1x = false;
209
210 if (pwr_topology_table_header.header_size <
211 VBIOS_POWER_TOPOLOGY_2X_HEADER_SIZE_06) {
212 status = -EINVAL;
213 goto done;
214 }
215
216 if (pwr_topology_table_header.table_entry_size !=
217 VBIOS_POWER_TOPOLOGY_2X_ENTRY_SIZE_16) {
218 status = -EINVAL;
219 goto done;
220 }
221
222 curr_pwr_topology_table_ptr = (pwr_topology_table_ptr +
223 VBIOS_POWER_TOPOLOGY_2X_HEADER_SIZE_06);
224
225 for (index = 0; index < pwr_topology_table_header.num_table_entries;
226 index++) {
227 u8 class_type;
228
229 curr_pwr_topology_table_ptr += (pwr_topology_table_header.table_entry_size * index);
230
231 pwr_topology_table_entry.flags0 = *curr_pwr_topology_table_ptr;
232 pwr_topology_table_entry.pwr_rail = *(curr_pwr_topology_table_ptr + 1);
233
234 memcpy(&pwr_topology_table_entry.param0,
235 (curr_pwr_topology_table_ptr + 2),
236 (VBIOS_POWER_TOPOLOGY_2X_ENTRY_SIZE_16 - 2));
237
238 class_type = (u8)BIOS_GET_FIELD(
239 pwr_topology_table_entry.flags0,
240 NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_FLAGS0_CLASS);
241
242 if (class_type == NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_FLAGS0_CLASS_SENSOR) {
243 pwr_topology_data.sensor.pwr_dev_idx = (u8)BIOS_GET_FIELD(
244 pwr_topology_table_entry.param1,
245 NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_PARAM1_SENSOR_INDEX);
246 pwr_topology_data.sensor.pwr_dev_prov_idx = (u8)BIOS_GET_FIELD(
247 pwr_topology_table_entry.param1,
248 NV_VBIOS_POWER_TOPOLOGY_2X_ENTRY_PARAM1_SENSOR_PROVIDER_INDEX);
249
250 pwr_topology_size = sizeof(struct pwr_channel_sensor);
251 } else
252 continue;
253
254 /* Initialize data for the parent class */
255 pwr_topology_data.boardobj.type = CTRL_PMGR_PWR_CHANNEL_TYPE_SENSOR;
256 pwr_topology_data.pwrchannel.pwr_rail = (u8)pwr_topology_table_entry.pwr_rail;
257 pwr_topology_data.pwrchannel.volt_fixed_uv = pwr_topology_table_entry.param0;
258 pwr_topology_data.pwrchannel.pwr_corr_slope = (1 << 12);
259 pwr_topology_data.pwrchannel.pwr_corr_offset_mw = 0;
260 pwr_topology_data.pwrchannel.curr_corr_slope =
261 (u32)pwr_topology_table_entry.curr_corr_slope;
262 pwr_topology_data.pwrchannel.curr_corr_offset_ma =
263 (s32)pwr_topology_table_entry.curr_corr_offset;
264
265 boardobj = construct_pwr_topology(g, &pwr_topology_data,
266 pwr_topology_size, pwr_topology_data.boardobj.type);
267
268 if (!boardobj) {
269 gk20a_err(dev_from_gk20a(g),
270 "unable to create pwr topology for %d type %d",
271 index, pwr_topology_data.boardobj.type);
272 status = -EINVAL;
273 goto done;
274 }
275
276 status = boardobjgrp_objinsert(&ppwrmonitorobjs->pwr_channels.super,
277 boardobj, obj_index);
278
279 if (status) {
280 gk20a_err(dev_from_gk20a(g),
281 "unable to insert pwr topology boardobj for %d", index);
282 status = -EINVAL;
283 goto done;
284 }
285
286 ++obj_index;
287 }
288
289done:
290 gk20a_dbg_info(" done status %x", status);
291 return status;
292}
293
294u32 pmgr_monitor_sw_setup(struct gk20a *g)
295{
296 u32 status;
297 struct boardobjgrp *pboardobjgrp = NULL;
298 struct pwr_channel *pchannel;
299 struct pmgr_pwr_monitor *ppwrmonitorobjs;
300 u8 indx = 0;
301
302 /* Construct the Super Class and override the Interfaces */
303 status = boardobjgrpconstruct_e32(
304 &g->pmgr_pmu.pmgr_monitorobjs.pwr_channels);
305 if (status) {
306 gk20a_err(dev_from_gk20a(g),
307 "error creating boardobjgrp for pmgr channel, status - 0x%x",
308 status);
309 goto done;
310 }
311
312 pboardobjgrp = &(g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super);
313
314 /* Override the Interfaces */
315 pboardobjgrp->pmudatainstget = _pwr_channel_pmudata_instget;
316
317 /* Construct the Super Class and override the Interfaces */
318 status = boardobjgrpconstruct_e32(
319 &g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels);
320 if (status) {
321 gk20a_err(dev_from_gk20a(g),
322 "error creating boardobjgrp for pmgr channel relationship, status - 0x%x",
323 status);
324 goto done;
325 }
326
327 pboardobjgrp = &(g->pmgr_pmu.pmgr_monitorobjs.pwr_ch_rels.super);
328
329 /* Override the Interfaces */
330 pboardobjgrp->pmudatainstget = _pwr_channel_rels_pmudata_instget;
331
332 /* Initialize the Total GPU Power Channel Mask to 0 */
333 g->pmgr_pmu.pmgr_monitorobjs.pmu_data.channels.hdr.data.total_gpu_power_channel_mask = 0;
334 g->pmgr_pmu.pmgr_monitorobjs.total_gpu_channel_idx =
335 CTRL_PMGR_PWR_CHANNEL_INDEX_INVALID;
336
337 /* Supported topology table version 1.0 */
338 g->pmgr_pmu.pmgr_monitorobjs.b_is_topology_tbl_ver_1x = true;
339
340 ppwrmonitorobjs = &(g->pmgr_pmu.pmgr_monitorobjs);
341
342 status = devinit_get_pwr_topology_table(g, ppwrmonitorobjs);
343 if (status)
344 goto done;
345
346 status = _pwr_channel_state_init(g);
347 if (status)
348 goto done;
349
350 /* Initialise physicalChannelMask */
351 g->pmgr_pmu.pmgr_monitorobjs.physical_channel_mask = 0;
352
353 pboardobjgrp = &g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super;
354
355 BOARDOBJGRP_FOR_EACH(pboardobjgrp, struct pwr_channel *, pchannel, indx) {
356 if (_pwr_channel_implements(pchannel,
357 CTRL_PMGR_PWR_CHANNEL_TYPE_SENSOR)) {
358 g->pmgr_pmu.pmgr_monitorobjs.physical_channel_mask |= BIT(indx);
359 }
360 }
361
362done:
363 gk20a_dbg_info(" done status %x", status);
364 return status;
365}
diff --git a/drivers/gpu/nvgpu/pmgr/pwrmonitor.h b/drivers/gpu/nvgpu/pmgr/pwrmonitor.h
new file mode 100644
index 00000000..7cd6b8c9
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pwrmonitor.h
@@ -0,0 +1,60 @@
1/*
2 * general power channel structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _PWRMONITOR_H_
16#define _PWRMONITOR_H_
17
18#include "boardobj/boardobjgrp.h"
19#include "boardobj/boardobj.h"
20#include "pmuif/gpmuifpmgr.h"
21#include "ctrl/ctrlpmgr.h"
22
23struct pwr_channel {
24 struct boardobj super;
25 u8 pwr_rail;
26 u32 volt_fixed_uv;
27 u32 pwr_corr_slope;
28 s32 pwr_corr_offset_mw;
29 u32 curr_corr_slope;
30 s32 curr_corr_offset_ma;
31 u32 dependent_ch_mask;
32};
33
34struct pwr_chrelationship {
35 struct boardobj super;
36 u8 chIdx;
37};
38
39struct pwr_channel_sensor {
40 struct pwr_channel super;
41 u8 pwr_dev_idx;
42 u8 pwr_dev_prov_idx;
43};
44
45struct pmgr_pwr_monitor {
46 bool b_is_topology_tbl_ver_1x;
47 struct boardobjgrp_e32 pwr_channels;
48 struct boardobjgrp_e32 pwr_ch_rels;
49 u8 total_gpu_channel_idx;
50 u32 physical_channel_mask;
51 struct nv_pmu_pmgr_pwr_monitor_pack pmu_data;
52};
53
54#define PMGR_PWR_MONITOR_GET_PWR_CHANNEL(g, channel_idx) \
55 ((struct pwr_channel *)BOARDOBJGRP_OBJ_GET_BY_IDX( \
56 &(g->pmgr_pmu.pmgr_monitorobjs.pwr_channels.super), (channel_idx)))
57
58u32 pmgr_monitor_sw_setup(struct gk20a *g);
59
60#endif
diff --git a/drivers/gpu/nvgpu/pmgr/pwrpolicy.c b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
new file mode 100644
index 00000000..d7926773
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pwrpolicy.c
@@ -0,0 +1,765 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "pwrpolicy.h"
16#include "include/bios.h"
17#include "boardobj/boardobjgrp.h"
18#include "boardobj/boardobjgrp_e32.h"
19#include "pmuif/gpmuifboardobj.h"
20#include "pmuif/gpmuifpmgr.h"
21#include "gm206/bios_gm206.h"
22#include "gk20a/pmu_gk20a.h"
23
24#define _pwr_policy_limitarboutputget_helper(p_limit_arb) (p_limit_arb)->output
25#define _pwr_policy_limitdeltaapply(limit, delta) ((u32)max(((s32)limit) + (delta), 0))
26
27static u32 _pwr_policy_limitarbinputset_helper(struct gk20a *g,
28 struct ctrl_pmgr_pwr_policy_limit_arbitration *p_limit_arb,
29 u8 client_idx,
30 u32 limit_value)
31{
32 u8 indx;
33 bool b_found = false;
34 u32 status = 0;
35 u32 output = limit_value;
36
37 for (indx = 0; indx< p_limit_arb->num_inputs; indx++) {
38 if (p_limit_arb->inputs[indx].pwr_policy_idx == client_idx) {
39 p_limit_arb->inputs[indx].limit_value = limit_value;
40 b_found = true;
41 } else if (p_limit_arb->b_arb_max) {
42 output = max(output, p_limit_arb->inputs[indx].limit_value);
43 } else {
44 output = min(output, p_limit_arb->inputs[indx].limit_value);
45 }
46 }
47
48 if (!b_found) {
49 if (p_limit_arb->num_inputs <
50 CTRL_PMGR_PWR_POLICY_MAX_LIMIT_INPUTS) {
51 p_limit_arb->inputs[
52 p_limit_arb->num_inputs].pwr_policy_idx = client_idx;
53 p_limit_arb->inputs[
54 p_limit_arb->num_inputs].limit_value = limit_value;
55 p_limit_arb->num_inputs++;
56 } else {
57 gk20a_err(g->dev, "No entries remaining for clientIdx=%d",
58 client_idx);
59 status = -EINVAL;
60 }
61 }
62
63 if (!status) {
64 p_limit_arb->output = output;
65 }
66
67 return status;
68}
69
70static u32 _pwr_policy_limitid_translate(struct gk20a *g,
71 struct pwr_policy *ppolicy,
72 enum pwr_policy_limit_id limit_id,
73 struct ctrl_pmgr_pwr_policy_limit_arbitration **p_limit_arb,
74 struct ctrl_pmgr_pwr_policy_limit_arbitration **p_limit_arb_sec)
75{
76 u32 status = 0;
77
78 switch (limit_id) {
79 case PWR_POLICY_LIMIT_ID_MIN:
80 *p_limit_arb = &ppolicy->limit_arb_min;
81 break;
82
83 case PWR_POLICY_LIMIT_ID_RATED:
84 *p_limit_arb = &ppolicy->limit_arb_rated;
85
86 if (p_limit_arb_sec != NULL) {
87 *p_limit_arb_sec = &ppolicy->limit_arb_curr;
88 }
89 break;
90
91 case PWR_POLICY_LIMIT_ID_MAX:
92 *p_limit_arb = &ppolicy->limit_arb_max;
93 break;
94
95 case PWR_POLICY_LIMIT_ID_CURR:
96 *p_limit_arb = &ppolicy->limit_arb_curr;
97 break;
98
99 case PWR_POLICY_LIMIT_ID_BATT:
100 *p_limit_arb = &ppolicy->limit_arb_batt;
101 break;
102
103 default:
104 gk20a_err(g->dev, "Unsupported limitId=%d",
105 limit_id);
106 status = -EINVAL;
107 break;
108 }
109
110 return status;
111}
112
113static u32 _pwr_policy_limitarbinputset(struct gk20a *g,
114 struct pwr_policy *ppolicy,
115 enum pwr_policy_limit_id limit_id,
116 u8 client_idx,
117 u32 limit)
118{
119 u32 status = 0;
120 struct ctrl_pmgr_pwr_policy_limit_arbitration *p_limit_arb = NULL;
121 struct ctrl_pmgr_pwr_policy_limit_arbitration *p_limit_arb_sec = NULL;
122
123 status = _pwr_policy_limitid_translate(g,
124 ppolicy,
125 limit_id,
126 &p_limit_arb,
127 &p_limit_arb_sec);
128 if (status) {
129 goto exit;
130 }
131
132 status = _pwr_policy_limitarbinputset_helper(g, p_limit_arb, client_idx, limit);
133 if (status) {
134 gk20a_err(g->dev,
135 "Error setting client limit value: status=0x%08x, limitId=0x%x, clientIdx=0x%x, limit=%d",
136 status, limit_id, client_idx, limit);
137 goto exit;
138 }
139
140 if (NULL != p_limit_arb_sec) {
141 status = _pwr_policy_limitarbinputset_helper(g, p_limit_arb_sec,
142 CTRL_PMGR_PWR_POLICY_LIMIT_INPUT_CLIENT_IDX_RM,
143 _pwr_policy_limitarboutputget_helper(p_limit_arb));
144 }
145
146exit:
147 return status;
148}
149
150static inline void _pwr_policy_limitarbconstruct(
151 struct ctrl_pmgr_pwr_policy_limit_arbitration *p_limit_arb,
152 bool b_arb_max)
153{
154 p_limit_arb->num_inputs = 0;
155 p_limit_arb->b_arb_max = b_arb_max;
156}
157
158static u32 _pwr_policy_limitarboutputget(struct gk20a *g,
159 struct pwr_policy *ppolicy,
160 enum pwr_policy_limit_id limit_id)
161{
162 u32 status = 0;
163 struct ctrl_pmgr_pwr_policy_limit_arbitration *p_limit_arb = NULL;
164
165 status = _pwr_policy_limitid_translate(g,
166 ppolicy,
167 limit_id,
168 &p_limit_arb,
169 NULL);
170 if (status) {
171 return 0;
172 }
173
174 return _pwr_policy_limitarboutputget_helper(p_limit_arb);
175}
176
177static u32 _pwr_domains_pmudatainit_hw_threshold(struct gk20a *g,
178 struct boardobj *board_obj_ptr,
179 struct nv_pmu_boardobj *ppmudata)
180{
181 struct nv_pmu_pmgr_pwr_policy_hw_threshold *pmu_hw_threshold_data;
182 struct pwr_policy_hw_threshold *p_hw_threshold;
183 struct pwr_policy *p_pwr_policy;
184 struct nv_pmu_pmgr_pwr_policy *pmu_pwr_policy;
185 u32 status = 0;
186
187 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
188 if (status) {
189 gk20a_err(dev_from_gk20a(g),
190 "error updating pmu boardobjgrp for pwr sensor 0x%x",
191 status);
192 status = -ENOMEM;
193 goto done;
194 }
195
196 p_hw_threshold = (struct pwr_policy_hw_threshold *)board_obj_ptr;
197 pmu_hw_threshold_data = (struct nv_pmu_pmgr_pwr_policy_hw_threshold *) ppmudata;
198 pmu_pwr_policy = (struct nv_pmu_pmgr_pwr_policy *) ppmudata;
199 p_pwr_policy = (struct pwr_policy *)&(p_hw_threshold->super.super);
200
201 pmu_pwr_policy->ch_idx = 0;
202 pmu_pwr_policy->limit_unit = p_pwr_policy->limit_unit;
203 pmu_pwr_policy->num_limit_inputs = p_pwr_policy->num_limit_inputs;
204
205 pmu_pwr_policy->limit_min = _pwr_policy_limitdeltaapply(
206 _pwr_policy_limitarboutputget(g, p_pwr_policy,
207 PWR_POLICY_LIMIT_ID_MIN),
208 p_pwr_policy->limit_delta);
209
210 pmu_pwr_policy->limit_max = _pwr_policy_limitdeltaapply(
211 _pwr_policy_limitarboutputget(g, p_pwr_policy,
212 PWR_POLICY_LIMIT_ID_MAX),
213 p_pwr_policy->limit_delta);
214
215 pmu_pwr_policy->limit_curr = _pwr_policy_limitdeltaapply(
216 _pwr_policy_limitarboutputget(g, p_pwr_policy,
217 PWR_POLICY_LIMIT_ID_CURR),
218 p_pwr_policy->limit_delta);
219
220 memcpy(&pmu_pwr_policy->integral, &p_pwr_policy->integral,
221 sizeof(struct ctrl_pmgr_pwr_policy_info_integral));
222
223 pmu_pwr_policy->sample_mult = p_pwr_policy->sample_mult;
224 pmu_pwr_policy->filter_type = p_pwr_policy->filter_type;
225 pmu_pwr_policy->filter_param = p_pwr_policy->filter_param;
226
227 pmu_hw_threshold_data->threshold_idx = p_hw_threshold->threshold_idx;
228 pmu_hw_threshold_data->low_threshold_idx = p_hw_threshold->low_threshold_idx;
229 pmu_hw_threshold_data->b_use_low_threshold = p_hw_threshold->b_use_low_threshold;
230 pmu_hw_threshold_data->low_threshold_value = p_hw_threshold->low_threshold_value;
231
232 if (BOARDOBJ_GET_TYPE(board_obj_ptr) ==
233 CTRL_PMGR_PWR_POLICY_TYPE_SW_THRESHOLD) {
234 struct nv_pmu_pmgr_pwr_policy_sw_threshold *pmu_sw_threshold_data;
235 struct pwr_policy_sw_threshold *p_sw_threshold;
236
237 p_sw_threshold = (struct pwr_policy_sw_threshold *)board_obj_ptr;
238 pmu_sw_threshold_data =
239 (struct nv_pmu_pmgr_pwr_policy_sw_threshold *) ppmudata;
240 pmu_sw_threshold_data->event_id =
241 p_sw_threshold->event_id;
242 }
243done:
244 return status;
245}
246
247static struct boardobj *construct_pwr_policy(struct gk20a *g,
248 void *pargs, u16 pargs_size, u8 type)
249{
250 struct boardobj *board_obj_ptr = NULL;
251 u32 status;
252 struct pwr_policy_hw_threshold *pwrpolicyhwthreshold;
253 struct pwr_policy *pwrpolicy;
254 struct pwr_policy *pwrpolicyparams = (struct pwr_policy*)pargs;
255 struct pwr_policy_hw_threshold *hwthreshold = (struct pwr_policy_hw_threshold*)pargs;
256
257 status = boardobj_construct_super(g, &board_obj_ptr,
258 pargs_size, pargs);
259 if (status)
260 return NULL;
261
262 pwrpolicyhwthreshold = (struct pwr_policy_hw_threshold*)board_obj_ptr;
263 pwrpolicy = (struct pwr_policy *)board_obj_ptr;
264
265 /* Set Super class interfaces */
266 board_obj_ptr->pmudatainit = _pwr_domains_pmudatainit_hw_threshold;
267
268 pwrpolicy->ch_idx = pwrpolicyparams->ch_idx;
269 pwrpolicy->num_limit_inputs = 0;
270 pwrpolicy->limit_unit = pwrpolicyparams->limit_unit;
271 pwrpolicy->filter_type = (enum ctrl_pmgr_pwr_policy_filter_type)(pwrpolicyparams->filter_type);
272 pwrpolicy->sample_mult = pwrpolicyparams->sample_mult;
273 switch (pwrpolicy->filter_type)
274 {
275 case CTRL_PMGR_PWR_POLICY_FILTER_TYPE_NONE:
276 break;
277
278 case CTRL_PMGR_PWR_POLICY_FILTER_TYPE_BLOCK:
279 pwrpolicy->filter_param.block.block_size =
280 pwrpolicyparams->filter_param.block.block_size;
281 break;
282
283 case CTRL_PMGR_PWR_POLICY_FILTER_TYPE_MOVING_AVERAGE:
284 pwrpolicy->filter_param.moving_avg.window_size =
285 pwrpolicyparams->filter_param.moving_avg.window_size;
286 break;
287
288 case CTRL_PMGR_PWR_POLICY_FILTER_TYPE_IIR:
289 pwrpolicy->filter_param.iir.divisor = pwrpolicyparams->filter_param.iir.divisor;
290 break;
291
292 default:
293 gk20a_err(g->dev,
294 "Error: unrecognized Power Policy filter type: %d.\n",
295 pwrpolicy->filter_type);
296 }
297
298 _pwr_policy_limitarbconstruct(&pwrpolicy->limit_arb_curr, false);
299
300 pwrpolicy->limit_delta = 0;
301
302 _pwr_policy_limitarbconstruct(&pwrpolicy->limit_arb_min, true);
303 status = _pwr_policy_limitarbinputset(g,
304 pwrpolicy,
305 PWR_POLICY_LIMIT_ID_MIN,
306 CTRL_PMGR_PWR_POLICY_LIMIT_INPUT_CLIENT_IDX_RM,
307 pwrpolicyparams->limit_min);
308
309 _pwr_policy_limitarbconstruct(&pwrpolicy->limit_arb_max, false);
310 status = _pwr_policy_limitarbinputset(g,
311 pwrpolicy,
312 PWR_POLICY_LIMIT_ID_MAX,
313 CTRL_PMGR_PWR_POLICY_LIMIT_INPUT_CLIENT_IDX_RM,
314 pwrpolicyparams->limit_max);
315
316 _pwr_policy_limitarbconstruct(&pwrpolicy->limit_arb_rated, false);
317 status = _pwr_policy_limitarbinputset(g,
318 pwrpolicy,
319 PWR_POLICY_LIMIT_ID_RATED,
320 CTRL_PMGR_PWR_POLICY_LIMIT_INPUT_CLIENT_IDX_RM,
321 pwrpolicyparams->limit_rated);
322
323 _pwr_policy_limitarbconstruct(&pwrpolicy->limit_arb_batt, false);
324 status = _pwr_policy_limitarbinputset(g,
325 pwrpolicy,
326 PWR_POLICY_LIMIT_ID_BATT,
327 CTRL_PMGR_PWR_POLICY_LIMIT_INPUT_CLIENT_IDX_RM,
328 ((pwrpolicyparams->limit_batt != 0) ?
329 pwrpolicyparams->limit_batt:
330 CTRL_PMGR_PWR_POLICY_LIMIT_MAX));
331
332 memcpy(&pwrpolicy->integral, &pwrpolicyparams->integral,
333 sizeof(struct ctrl_pmgr_pwr_policy_info_integral));
334
335 pwrpolicyhwthreshold->threshold_idx = hwthreshold->threshold_idx;
336 pwrpolicyhwthreshold->b_use_low_threshold = hwthreshold->b_use_low_threshold;
337 pwrpolicyhwthreshold->low_threshold_idx = hwthreshold->low_threshold_idx;
338 pwrpolicyhwthreshold->low_threshold_value = hwthreshold->low_threshold_value;
339
340 if (type == CTRL_PMGR_PWR_POLICY_TYPE_SW_THRESHOLD) {
341 struct pwr_policy_sw_threshold *pwrpolicyswthreshold;
342 struct pwr_policy_sw_threshold *swthreshold =
343 (struct pwr_policy_sw_threshold*)pargs;
344
345 pwrpolicyswthreshold = (struct pwr_policy_sw_threshold*)board_obj_ptr;
346 pwrpolicyswthreshold->event_id = swthreshold->event_id;
347 }
348
349 gk20a_dbg_info(" Done");
350
351 return board_obj_ptr;
352}
353
354static u32 _pwr_policy_construct_WAR_policy(struct gk20a *g,
355 struct pmgr_pwr_policy *ppwrpolicyobjs,
356 union pwr_policy_data_union *ppwrpolicydata,
357 u16 pwr_policy_size,
358 u32 hw_threshold_policy_index,
359 u32 obj_index)
360{
361 u32 status = 0;
362 struct boardobj *boardobj;
363
364 if (!(hw_threshold_policy_index & 0x1)) {
365 /* CRIT policy */
366 ppwrpolicydata->pwrpolicy.limit_min = 1000;
367 ppwrpolicydata->pwrpolicy.limit_rated = 20000;
368 ppwrpolicydata->pwrpolicy.limit_max = 20000;
369 ppwrpolicydata->hw_threshold.threshold_idx = 0;
370 } else {
371 /* WARN policy */
372 ppwrpolicydata->pwrpolicy.limit_min = 1000;
373 ppwrpolicydata->pwrpolicy.limit_rated = 11600;
374 ppwrpolicydata->pwrpolicy.limit_max = 11600;
375 ppwrpolicydata->hw_threshold.threshold_idx = 1;
376 }
377
378 boardobj = construct_pwr_policy(g, ppwrpolicydata,
379 pwr_policy_size, ppwrpolicydata->boardobj.type);
380
381 if (!boardobj) {
382 gk20a_err(dev_from_gk20a(g),
383 "unable to create pwr policy for type %d", ppwrpolicydata->boardobj.type);
384 status = -EINVAL;
385 goto done;
386 }
387
388 status = boardobjgrp_objinsert(&ppwrpolicyobjs->pwr_policies.super,
389 boardobj, obj_index);
390
391 if (status) {
392 gk20a_err(dev_from_gk20a(g),
393 "unable to insert pwr policy boardobj for %d", obj_index);
394 status = -EINVAL;
395 goto done;
396 }
397done:
398 return status;
399}
400
401static u32 _pwr_policy_construct_WAR_SW_Threshold_policy(struct gk20a *g,
402 struct pmgr_pwr_policy *ppwrpolicyobjs,
403 union pwr_policy_data_union *ppwrpolicydata,
404 u16 pwr_policy_size,
405 u32 obj_index)
406{
407 u32 status = 0;
408 struct boardobj *boardobj;
409
410 /* WARN policy */
411 ppwrpolicydata->pwrpolicy.limit_unit = 0;
412 ppwrpolicydata->pwrpolicy.limit_min = 10000;
413 ppwrpolicydata->pwrpolicy.limit_rated = 100000;
414 ppwrpolicydata->pwrpolicy.limit_max = 100000;
415 ppwrpolicydata->sw_threshold.threshold_idx = 1;
416 ppwrpolicydata->pwrpolicy.filter_type =
417 CTRL_PMGR_PWR_POLICY_FILTER_TYPE_MOVING_AVERAGE;
418 ppwrpolicydata->pwrpolicy.sample_mult = 5;
419
420 /* Filled the entry.filterParam value in the filterParam */
421 ppwrpolicydata->pwrpolicy.filter_param.moving_avg.window_size = 10;
422
423 ppwrpolicydata->sw_threshold.event_id = 0x01;
424
425 ppwrpolicydata->boardobj.type = CTRL_PMGR_PWR_POLICY_TYPE_SW_THRESHOLD;
426
427 boardobj = construct_pwr_policy(g, ppwrpolicydata,
428 pwr_policy_size, ppwrpolicydata->boardobj.type);
429
430 if (!boardobj) {
431 gk20a_err(dev_from_gk20a(g),
432 "unable to create pwr policy for type %d", ppwrpolicydata->boardobj.type);
433 status = -EINVAL;
434 goto done;
435 }
436
437 status = boardobjgrp_objinsert(&ppwrpolicyobjs->pwr_policies.super,
438 boardobj, obj_index);
439
440 if (status) {
441 gk20a_err(dev_from_gk20a(g),
442 "unable to insert pwr policy boardobj for %d", obj_index);
443 status = -EINVAL;
444 goto done;
445 }
446done:
447 return status;
448}
449
450static u32 devinit_get_pwr_policy_table(struct gk20a *g,
451 struct pmgr_pwr_policy *ppwrpolicyobjs)
452{
453 u32 status = 0;
454 u8 *pwr_policy_table_ptr = NULL;
455 u8 *curr_pwr_policy_table_ptr = NULL;
456 struct boardobj *boardobj;
457 struct pwr_policy_3x_header_struct pwr_policy_table_header = { 0 };
458 struct pwr_policy_3x_entry_struct pwr_policy_table_entry = { 0 };
459 u32 index;
460 u32 obj_index = 0;
461 u16 pwr_policy_size;
462 bool integral_control = false;
463 u32 hw_threshold_policy_index = 0;
464 u32 sw_threshold_policy_index = 0;
465 union pwr_policy_data_union pwr_policy_data;
466
467 gk20a_dbg_info("");
468
469 if (g->ops.bios.get_perf_table_ptrs != NULL) {
470 pwr_policy_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
471 g->bios.perf_token, POWER_CAPPING_TABLE);
472 if (pwr_policy_table_ptr == NULL) {
473 status = -EINVAL;
474 goto done;
475 }
476 }
477
478 memcpy(&pwr_policy_table_header.version,
479 (pwr_policy_table_ptr),
480 14);
481
482 memcpy(&pwr_policy_table_header.d2_limit,
483 (pwr_policy_table_ptr + 14),
484 (VBIOS_POWER_POLICY_3X_ENTRY_SIZE_2E - 14));
485
486 if (pwr_policy_table_header.version !=
487 VBIOS_POWER_POLICY_VERSION_3X) {
488 status = -EINVAL;
489 goto done;
490 }
491
492 if (pwr_policy_table_header.header_size <
493 VBIOS_POWER_POLICY_3X_HEADER_SIZE_25) {
494 status = -EINVAL;
495 goto done;
496 }
497
498 if (pwr_policy_table_header.table_entry_size !=
499 VBIOS_POWER_POLICY_3X_ENTRY_SIZE_2E) {
500 status = -EINVAL;
501 goto done;
502 }
503
504 curr_pwr_policy_table_ptr = (pwr_policy_table_ptr +
505 VBIOS_POWER_POLICY_3X_HEADER_SIZE_25);
506
507 for (index = 0; index < pwr_policy_table_header.num_table_entries;
508 index++) {
509 u8 class_type;
510
511 curr_pwr_policy_table_ptr += (pwr_policy_table_header.table_entry_size * index);
512
513 pwr_policy_table_entry.flags0 = *curr_pwr_policy_table_ptr;
514 pwr_policy_table_entry.ch_idx = *(curr_pwr_policy_table_ptr + 1);
515
516 memcpy(&pwr_policy_table_entry.limit_min,
517 (curr_pwr_policy_table_ptr + 2),
518 35);
519
520 memcpy(&pwr_policy_table_entry.ratio_min,
521 (curr_pwr_policy_table_ptr + 2 + 35),
522 4);
523
524 pwr_policy_table_entry.sample_mult =
525 *(curr_pwr_policy_table_ptr + 2 + 35 + 4);
526
527 memcpy(&pwr_policy_table_entry.filter_param,
528 (curr_pwr_policy_table_ptr + 2 + 35 + 4 + 1),
529 4);
530
531 class_type = (u8)BIOS_GET_FIELD(
532 pwr_policy_table_entry.flags0,
533 NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS0_CLASS);
534
535 if (class_type == NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS0_CLASS_HW_THRESHOLD) {
536 ppwrpolicyobjs->version = CTRL_PMGR_PWR_POLICY_TABLE_VERSION_3X;
537 ppwrpolicyobjs->base_sample_period = (u16)
538 pwr_policy_table_header.base_sample_period;
539 ppwrpolicyobjs->min_client_sample_period = (u16)
540 pwr_policy_table_header.min_client_sample_period;
541 ppwrpolicyobjs->low_sampling_mult =
542 pwr_policy_table_header.low_sampling_mult;
543
544 ppwrpolicyobjs->policy_idxs[1] =
545 (u8)pwr_policy_table_header.tgp_policy_idx;
546 ppwrpolicyobjs->policy_idxs[0] =
547 (u8)pwr_policy_table_header.rtp_policy_idx;
548 ppwrpolicyobjs->policy_idxs[2] =
549 pwr_policy_table_header.mxm_policy_idx;
550 ppwrpolicyobjs->policy_idxs[3] =
551 pwr_policy_table_header.dnotifier_policy_idx;
552 ppwrpolicyobjs->ext_limits[0].limit =
553 pwr_policy_table_header.d2_limit;
554 ppwrpolicyobjs->ext_limits[1].limit =
555 pwr_policy_table_header.d3_limit;
556 ppwrpolicyobjs->ext_limits[2].limit =
557 pwr_policy_table_header.d4_limit;
558 ppwrpolicyobjs->ext_limits[3].limit =
559 pwr_policy_table_header.d5_limit;
560 ppwrpolicyobjs->policy_idxs[4] =
561 pwr_policy_table_header.pwr_tgt_policy_idx;
562 ppwrpolicyobjs->policy_idxs[5] =
563 pwr_policy_table_header.pwr_tgt_floor_policy_idx;
564 ppwrpolicyobjs->policy_idxs[6] =
565 pwr_policy_table_header.sm_bus_policy_idx;
566
567 integral_control = (bool)BIOS_GET_FIELD(
568 pwr_policy_table_entry.flags1,
569 NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS1_INTEGRAL_CONTROL);
570
571 if (integral_control == 0x01) {
572 pwr_policy_data.pwrpolicy.integral.past_sample_count = (u8)
573 pwr_policy_table_entry.past_length;
574 pwr_policy_data.pwrpolicy.integral.next_sample_count = (u8)
575 pwr_policy_table_entry.next_length;
576 pwr_policy_data.pwrpolicy.integral.ratio_limit_max = (u16)
577 pwr_policy_table_entry.ratio_max;
578 pwr_policy_data.pwrpolicy.integral.ratio_limit_min = (u16)
579 pwr_policy_table_entry.ratio_min;
580 } else {
581 memset(&(pwr_policy_data.pwrpolicy.integral), 0x0,
582 sizeof(struct ctrl_pmgr_pwr_policy_info_integral));
583 }
584 pwr_policy_data.hw_threshold.threshold_idx = (u8)
585 BIOS_GET_FIELD(
586 pwr_policy_table_entry.param0,
587 NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM0_HW_THRESHOLD_THRES_IDX);
588
589 pwr_policy_data.hw_threshold.b_use_low_threshold =
590 BIOS_GET_FIELD(
591 pwr_policy_table_entry.param0,
592 NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM0_HW_THRESHOLD_LOW_THRESHOLD_USE);
593
594 if (pwr_policy_data.hw_threshold.b_use_low_threshold) {
595 pwr_policy_data.hw_threshold.low_threshold_idx = (u8)
596 BIOS_GET_FIELD(
597 pwr_policy_table_entry.param0,
598 NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM0_HW_THRESHOLD_LOW_THRESHOLD_IDX);
599
600 pwr_policy_data.hw_threshold.low_threshold_value = (u16)
601 BIOS_GET_FIELD(
602 pwr_policy_table_entry.param1,
603 NV_VBIOS_POWER_POLICY_3X_ENTRY_PARAM1_HW_THRESHOLD_LOW_THRESHOLD_VAL);
604 }
605
606 pwr_policy_size = sizeof(struct pwr_policy_hw_threshold);
607 } else
608 continue;
609
610 /* Initialize data for the parent class */
611 pwr_policy_data.boardobj.type = CTRL_PMGR_PWR_POLICY_TYPE_HW_THRESHOLD;
612 pwr_policy_data.pwrpolicy.ch_idx = (u8)pwr_policy_table_entry.ch_idx;
613 pwr_policy_data.pwrpolicy.limit_unit = (u8)
614 BIOS_GET_FIELD(
615 pwr_policy_table_entry.flags0,
616 NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS0_LIMIT_UNIT);
617 pwr_policy_data.pwrpolicy.filter_type = (u8)
618 BIOS_GET_FIELD(
619 pwr_policy_table_entry.flags1,
620 NV_VBIOS_POWER_POLICY_3X_ENTRY_FLAGS1_FILTER_TYPE);
621 pwr_policy_data.pwrpolicy.limit_min = pwr_policy_table_entry.limit_min;
622 pwr_policy_data.pwrpolicy.limit_rated = pwr_policy_table_entry.limit_rated;
623 pwr_policy_data.pwrpolicy.limit_max = pwr_policy_table_entry.limit_max;
624 pwr_policy_data.pwrpolicy.limit_batt = pwr_policy_table_entry.limit_batt;
625
626 pwr_policy_data.pwrpolicy.sample_mult = (u8)pwr_policy_table_entry.sample_mult;
627
628 /* Filled the entry.filterParam value in the filterParam */
629 pwr_policy_data.pwrpolicy.filter_param.block.block_size = 0;
630 pwr_policy_data.pwrpolicy.filter_param.moving_avg.window_size = 0;
631 pwr_policy_data.pwrpolicy.filter_param.iir.divisor = 0;
632
633 hw_threshold_policy_index |=
634 BIT(pwr_policy_data.hw_threshold.threshold_idx);
635
636 boardobj = construct_pwr_policy(g, &pwr_policy_data,
637 pwr_policy_size, pwr_policy_data.boardobj.type);
638
639 if (!boardobj) {
640 gk20a_err(dev_from_gk20a(g),
641 "unable to create pwr policy for %d type %d", index, pwr_policy_data.boardobj.type);
642 status = -EINVAL;
643 goto done;
644 }
645
646 status = boardobjgrp_objinsert(&ppwrpolicyobjs->pwr_policies.super,
647 boardobj, obj_index);
648
649 if (status) {
650 gk20a_err(dev_from_gk20a(g),
651 "unable to insert pwr policy boardobj for %d", index);
652 status = -EINVAL;
653 goto done;
654 }
655
656 ++obj_index;
657 }
658
659 if (hw_threshold_policy_index &&
660 (hw_threshold_policy_index < 0x3)) {
661 status = _pwr_policy_construct_WAR_policy(g,
662 ppwrpolicyobjs,
663 &pwr_policy_data,
664 pwr_policy_size,
665 hw_threshold_policy_index,
666 obj_index);
667 if (status) {
668 gk20a_err(dev_from_gk20a(g),
669 "unable to construct_WAR_policy");
670 status = -EINVAL;
671 goto done;
672 }
673 ++obj_index;
674 }
675
676 if (!sw_threshold_policy_index) {
677 status = _pwr_policy_construct_WAR_SW_Threshold_policy(g,
678 ppwrpolicyobjs,
679 &pwr_policy_data,
680 sizeof(struct pwr_policy_sw_threshold),
681 obj_index);
682 if (status) {
683 gk20a_err(dev_from_gk20a(g),
684 "unable to construct_WAR_policy");
685 status = -EINVAL;
686 goto done;
687 }
688 ++obj_index;
689 }
690
691done:
692 gk20a_dbg_info(" done status %x", status);
693 return status;
694}
695
696u32 pmgr_policy_sw_setup(struct gk20a *g)
697{
698 u32 status;
699 struct boardobjgrp *pboardobjgrp = NULL;
700 struct pwr_policy *ppolicy;
701 struct pmgr_pwr_policy *ppwrpolicyobjs;
702 u8 indx = 0;
703
704 /* Construct the Super Class and override the Interfaces */
705 status = boardobjgrpconstruct_e32(
706 &g->pmgr_pmu.pmgr_policyobjs.pwr_policies);
707 if (status) {
708 gk20a_err(dev_from_gk20a(g),
709 "error creating boardobjgrp for pmgr policy, status - 0x%x",
710 status);
711 goto done;
712 }
713
714 status = boardobjgrpconstruct_e32(
715 &g->pmgr_pmu.pmgr_policyobjs.pwr_policy_rels);
716 if (status) {
717 gk20a_err(dev_from_gk20a(g),
718 "error creating boardobjgrp for pmgr policy rels, status - 0x%x",
719 status);
720 goto done;
721 }
722
723 status = boardobjgrpconstruct_e32(
724 &g->pmgr_pmu.pmgr_policyobjs.pwr_violations);
725 if (status) {
726 gk20a_err(dev_from_gk20a(g),
727 "error creating boardobjgrp for pmgr violations, status - 0x%x",
728 status);
729 goto done;
730 }
731
732 memset(g->pmgr_pmu.pmgr_policyobjs.policy_idxs, CTRL_PMGR_PWR_POLICY_INDEX_INVALID,
733 sizeof(u8) * CTRL_PMGR_PWR_POLICY_IDX_NUM_INDEXES);
734
735 /* Initialize external power limit policy indexes to _INVALID/0xFF */
736 for (indx = 0; indx < PWR_POLICY_EXT_POWER_STATE_ID_COUNT; indx++) {
737 g->pmgr_pmu.pmgr_policyobjs.ext_limits[indx].policy_table_idx =
738 CTRL_PMGR_PWR_POLICY_INDEX_INVALID;
739 }
740
741 /* Initialize external power state to _D1 */
742 g->pmgr_pmu.pmgr_policyobjs.ext_power_state = 0xFFFFFFFF;
743
744 ppwrpolicyobjs = &(g->pmgr_pmu.pmgr_policyobjs);
745 pboardobjgrp = &(g->pmgr_pmu.pmgr_policyobjs.pwr_policies.super);
746
747 status = devinit_get_pwr_policy_table(g, ppwrpolicyobjs);
748 if (status)
749 goto done;
750
751 g->pmgr_pmu.pmgr_policyobjs.b_enabled = true;
752
753 BOARDOBJGRP_FOR_EACH(pboardobjgrp, struct pwr_policy *, ppolicy, indx) {
754 PMGR_PWR_POLICY_INCREMENT_LIMIT_INPUT_COUNT(ppolicy);
755 }
756
757 g->pmgr_pmu.pmgr_policyobjs.global_ceiling.values[0] =
758 0xFF;
759
760 g->pmgr_pmu.pmgr_policyobjs.client_work_item.b_pending = false;
761
762done:
763 gk20a_dbg_info(" done status %x", status);
764 return status;
765}
diff --git a/drivers/gpu/nvgpu/pmgr/pwrpolicy.h b/drivers/gpu/nvgpu/pmgr/pwrpolicy.h
new file mode 100644
index 00000000..008282d3
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmgr/pwrpolicy.h
@@ -0,0 +1,127 @@
1/*
2 * general power channel structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _PWRPOLICY_H_
16#define _PWRPOLICY_H_
17
18#include "boardobj/boardobjgrp.h"
19#include "boardobj/boardobj.h"
20#include "pmuif/gpmuifpmgr.h"
21#include "ctrl/ctrlpmgr.h"
22
23#define PWR_POLICY_EXT_POWER_STATE_ID_COUNT 0x4
24
25enum pwr_policy_limit_id {
26 PWR_POLICY_LIMIT_ID_MIN = 0x00000000,
27 PWR_POLICY_LIMIT_ID_RATED,
28 PWR_POLICY_LIMIT_ID_MAX,
29 PWR_POLICY_LIMIT_ID_CURR,
30 PWR_POLICY_LIMIT_ID_BATT,
31};
32
33struct pwr_policy {
34 struct boardobj super;
35 u8 ch_idx;
36 u8 num_limit_inputs;
37 u8 limit_unit;
38 s32 limit_delta;
39 u32 limit_min;
40 u32 limit_rated;
41 u32 limit_max;
42 u32 limit_batt;
43 struct ctrl_pmgr_pwr_policy_info_integral integral;
44 struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_min;
45 struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_rated;
46 struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_max;
47 struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_batt;
48 struct ctrl_pmgr_pwr_policy_limit_arbitration limit_arb_curr;
49 u8 sample_mult;
50 enum ctrl_pmgr_pwr_policy_filter_type filter_type;
51 union ctrl_pmgr_pwr_policy_filter_param filter_param;
52};
53
54struct pwr_policy_ext_limit {
55 u8 policy_table_idx;
56 u32 limit;
57};
58
59struct pwr_policy_batt_workitem {
60 u32 power_state;
61 bool b_full_deflection;
62};
63
64struct pwr_policy_client_workitem {
65 u32 limit;
66 bool b_pending;
67};
68
69struct pwr_policy_relationship {
70 struct boardobj super;
71 u8 policy_idx;
72};
73
74struct pmgr_pwr_policy {
75 u8 version;
76 bool b_enabled;
77 struct nv_pmu_perf_domain_group_limits global_ceiling;
78 u8 policy_idxs[CTRL_PMGR_PWR_POLICY_IDX_NUM_INDEXES];
79 struct pwr_policy_ext_limit ext_limits[PWR_POLICY_EXT_POWER_STATE_ID_COUNT];
80 s32 ext_power_state;
81 u16 base_sample_period;
82 u16 min_client_sample_period;
83 u8 low_sampling_mult;
84 struct boardobjgrp_e32 pwr_policies;
85 struct boardobjgrp_e32 pwr_policy_rels;
86 struct boardobjgrp_e32 pwr_violations;
87 struct pwr_policy_client_workitem client_work_item;
88};
89
90struct pwr_policy_limit {
91 struct pwr_policy super;
92};
93
94struct pwr_policy_hw_threshold {
95 struct pwr_policy_limit super;
96 u8 threshold_idx;
97 u8 low_threshold_idx;
98 bool b_use_low_threshold;
99 u16 low_threshold_value;
100};
101
102struct pwr_policy_sw_threshold {
103 struct pwr_policy_limit super;
104 u8 threshold_idx;
105 u8 low_threshold_idx;
106 bool b_use_low_threshold;
107 u16 low_threshold_value;
108 u8 event_id;
109};
110
111union pwr_policy_data_union {
112 struct boardobj boardobj;
113 struct pwr_policy pwrpolicy;
114 struct pwr_policy_hw_threshold hw_threshold;
115 struct pwr_policy_sw_threshold sw_threshold;
116} ;
117
118#define PMGR_GET_PWR_POLICY(g, policy_idx) \
119 ((struct pwr_policy *)BOARDOBJGRP_OBJ_GET_BY_IDX( \
120 &(g->pmgr_pmu.pmgr_policyobjs.pwr_policies.super), (policy_idx)))
121
122#define PMGR_PWR_POLICY_INCREMENT_LIMIT_INPUT_COUNT(ppolicy) \
123 ((ppolicy)->num_limit_inputs++)
124
125u32 pmgr_policy_sw_setup(struct gk20a *g);
126
127#endif
diff --git a/drivers/gpu/nvgpu/pmuif/gpmuifseq.h b/drivers/gpu/nvgpu/pmuif/gpmuifseq.h
new file mode 100644
index 00000000..69d55490
--- /dev/null
+++ b/drivers/gpu/nvgpu/pmuif/gpmuifseq.h
@@ -0,0 +1,73 @@
1/*
2* Copyright (c) 2016, 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#ifndef _GPMUIFSEQ_H_
14#define _GPMUIFSEQ_H_
15
16#include "gk20a/pmu_common.h"
17
18#define PMU_UNIT_SEQ (0x02)
19
20/*!
21* @file gpmuifseq.h
22* @brief PMU Command/Message Interfaces - Sequencer
23*/
24
25/*!
26* Defines the identifiers various high-level types of sequencer commands.
27*
28* _RUN_SCRIPT @ref NV_PMU_SEQ_CMD_RUN_SCRIPT
29*/
30enum {
31 NV_PMU_SEQ_CMD_ID_RUN_SCRIPT = 0,
32};
33
34struct nv_pmu_seq_cmd_run_script {
35 u8 cmd_type;
36 u8 pad[3];
37 struct pmu_allocation_v3 script_alloc;
38 struct pmu_allocation_v3 reg_alloc;
39};
40
41#define NV_PMU_SEQ_CMD_ALLOC_OFFSET 4
42
43#define NV_PMU_SEQ_MSG_ALLOC_OFFSET \
44 (NV_PMU_SEQ_CMD_ALLOC_OFFSET + NV_PMU_CMD_ALLOC_SIZE)
45
46struct nv_pmu_seq_cmd {
47 struct pmu_hdr hdr;
48 union {
49 u8 cmd_type;
50 struct nv_pmu_seq_cmd_run_script run_script;
51 };
52};
53
54enum {
55 NV_PMU_SEQ_MSG_ID_RUN_SCRIPT = 0,
56};
57
58struct nv_pmu_seq_msg_run_script {
59 u8 msg_type;
60 u8 error_code;
61 u16 error_pc;
62 u32 timeout_stat;
63};
64
65struct nv_pmu_seq_msg {
66 struct pmu_hdr hdr;
67 union {
68 u8 msg_type;
69 struct nv_pmu_seq_msg_run_script run_script;
70 };
71};
72
73#endif
diff --git a/drivers/gpu/nvgpu/pstate/pstate.c b/drivers/gpu/nvgpu/pstate/pstate.c
new file mode 100644
index 00000000..82e809bb
--- /dev/null
+++ b/drivers/gpu/nvgpu/pstate/pstate.c
@@ -0,0 +1,407 @@
1/*
2 * general p state infrastructure
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include "gk20a/gk20a.h"
17#include "clk/clk.h"
18#include "perf/perf.h"
19#include "pmgr/pmgr.h"
20#include "include/bios.h"
21#include "pstate/pstate.h"
22#include "therm/thrm.h"
23
24static int pstate_sw_setup(struct gk20a *g);
25
26/*sw setup for pstate components*/
27int gk20a_init_pstate_support(struct gk20a *g)
28{
29 u32 err;
30
31 gk20a_dbg_fn("");
32
33 err = volt_rail_sw_setup(g);
34 if (err)
35 return err;
36
37 err = volt_dev_sw_setup(g);
38 if (err)
39 return err;
40
41 err = volt_policy_sw_setup(g);
42 if (err)
43 return err;
44
45 err = clk_vin_sw_setup(g);
46 if (err)
47 return err;
48
49 err = clk_fll_sw_setup(g);
50 if (err)
51 return err;
52
53 err = therm_domain_sw_setup(g);
54 if (err)
55 return err;
56
57 err = vfe_var_sw_setup(g);
58 if (err)
59 return err;
60
61 err = vfe_equ_sw_setup(g);
62 if (err)
63 return err;
64
65 err = clk_domain_sw_setup(g);
66 if (err)
67 return err;
68
69 err = clk_vf_point_sw_setup(g);
70 if (err)
71 return err;
72
73 err = clk_prog_sw_setup(g);
74 if (err)
75 return err;
76
77 err = pstate_sw_setup(g);
78 if (err)
79 return err;
80
81 err = pmgr_domain_sw_setup(g);
82 if (err)
83 return err;
84
85 err = clk_freq_controller_sw_setup(g);
86 if (err)
87 return err;
88
89 err = nvgpu_lpwr_pg_setup(g);
90
91 return err;
92}
93
94/*sw setup for pstate components*/
95int gk20a_init_pstate_pmu_support(struct gk20a *g)
96{
97 u32 err;
98
99 gk20a_dbg_fn("");
100
101 err = volt_rail_pmu_setup(g);
102 if (err)
103 return err;
104
105 err = volt_dev_pmu_setup(g);
106 if (err)
107 return err;
108
109 err = volt_policy_pmu_setup(g);
110 if (err)
111 return err;
112
113 err = volt_pmu_send_load_cmd_to_pmu(g);
114 if (err) {
115 gk20a_err(dev_from_gk20a(g),
116 "Failed to send VOLT LOAD CMD to PMU: status = 0x%08x.",
117 err);
118 return err;
119 }
120
121 err = therm_domain_pmu_setup(g);
122 if (err)
123 return err;
124
125 err = vfe_var_pmu_setup(g);
126 if (err)
127 return err;
128
129 err = vfe_equ_pmu_setup(g);
130 if (err)
131 return err;
132
133 err = clk_domain_pmu_setup(g);
134 if (err)
135 return err;
136
137 err = clk_prog_pmu_setup(g);
138 if (err)
139 return err;
140
141 err = clk_vin_pmu_setup(g);
142 if (err)
143 return err;
144
145 err = clk_fll_pmu_setup(g);
146 if (err)
147 return err;
148
149 err = clk_vf_point_pmu_setup(g);
150 if (err)
151 return err;
152
153 err = clk_freq_controller_pmu_setup(g);
154 if (err)
155 return err;
156
157 err = clk_pmu_vin_load(g);
158 if (err)
159 return err;
160
161 err = perf_pmu_vfe_load(g);
162 if (err)
163 return err;
164
165 err = pmgr_domain_pmu_setup(g);
166 return err;
167}
168
169int pstate_construct_super(struct gk20a *g, struct boardobj **ppboardobj,
170 u16 size, void *args)
171{
172 struct pstate *ptmppstate = (struct pstate *)args;
173 struct pstate *pstate;
174 int err;
175
176 err = boardobj_construct_super(g, ppboardobj, size, args);
177 if (err)
178 return err;
179
180 pstate = (struct pstate *)*ppboardobj;
181
182 pstate->num = ptmppstate->num;
183 pstate->clklist = ptmppstate->clklist;
184 pstate->lpwr_entry_idx = ptmppstate->lpwr_entry_idx;
185
186 return 0;
187}
188
189int pstate_construct_3x(struct gk20a *g, struct boardobj **ppboardobj,
190 u16 size, void *args)
191{
192 struct boardobj *ptmpobj = (struct boardobj *)args;
193
194 ptmpobj->type_mask |= BIT(CTRL_PERF_PSTATE_TYPE_3X);
195 return pstate_construct_super(g, ppboardobj, size, args);
196}
197
198struct pstate *pstate_construct(struct gk20a *g, void *args)
199{
200 struct pstate *pstate = NULL;
201 struct pstate *tmp = (struct pstate *)args;
202
203 if ((tmp->super.type != CTRL_PERF_PSTATE_TYPE_3X) ||
204 (pstate_construct_3x(g, (struct boardobj **)&pstate,
205 sizeof(struct pstate), args)))
206 gk20a_err(dev_from_gk20a(g),
207 "error constructing pstate num=%u", tmp->num);
208
209 return pstate;
210}
211
212int pstate_insert(struct gk20a *g, struct pstate *pstate, int index)
213{
214 struct pstates *pstates = &(g->perf_pmu.pstatesobjs);
215 int err;
216
217 err = boardobjgrp_objinsert(&pstates->super.super,
218 (struct boardobj *)pstate, index);
219 if (err) {
220 gk20a_err(dev_from_gk20a(g),
221 "error adding pstate boardobj %d", index);
222 return err;
223 }
224
225 pstates->num_levels++;
226
227 return err;
228}
229
230static int parse_pstate_entry_5x(struct gk20a *g,
231 struct vbios_pstate_header_5x *hdr,
232 struct vbios_pstate_entry_5x *entry,
233 struct pstate *pstate)
234{
235 u8 *p = (u8 *)entry;
236 u32 clkidx;
237
238 p += hdr->base_entry_size;
239
240 memset(pstate, 0, sizeof(struct pstate));
241 pstate->super.type = CTRL_PERF_PSTATE_TYPE_3X;
242 pstate->num = 0x0F - entry->pstate_level;
243 pstate->clklist.num_info = hdr->clock_entry_count;
244 pstate->lpwr_entry_idx = entry->lpwr_entry_idx;
245
246 gk20a_dbg_info("pstate P%u", pstate->num);
247
248 for (clkidx = 0; clkidx < hdr->clock_entry_count; clkidx++) {
249 struct clk_set_info *pclksetinfo;
250 struct vbios_pstate_entry_clock_5x *clk_entry;
251 struct clk_domain *clk_domain;
252
253 clk_domain = (struct clk_domain *)BOARDOBJGRP_OBJ_GET_BY_IDX(
254 &g->clk_pmu.clk_domainobjs.super.super, clkidx);
255
256 pclksetinfo = &pstate->clklist.clksetinfo[clkidx];
257 clk_entry = (struct vbios_pstate_entry_clock_5x *)p;
258
259 pclksetinfo->clkwhich = clk_domain->domain;
260 pclksetinfo->nominal_mhz =
261 BIOS_GET_FIELD(clk_entry->param0,
262 VBIOS_PSTATE_5X_CLOCK_PROG_PARAM0_NOM_FREQ_MHZ);
263 pclksetinfo->min_mhz =
264 BIOS_GET_FIELD(clk_entry->param1,
265 VBIOS_PSTATE_5X_CLOCK_PROG_PARAM1_MIN_FREQ_MHZ);
266 pclksetinfo->max_mhz =
267 BIOS_GET_FIELD(clk_entry->param1,
268 VBIOS_PSTATE_5X_CLOCK_PROG_PARAM1_MAX_FREQ_MHZ);
269
270 gk20a_dbg_info(
271 "clk_domain=%u nominal_mhz=%u min_mhz=%u max_mhz=%u",
272 pclksetinfo->clkwhich, pclksetinfo->nominal_mhz,
273 pclksetinfo->min_mhz, pclksetinfo->max_mhz);
274
275 p += hdr->clock_entry_size;
276 }
277
278 return 0;
279}
280
281static int parse_pstate_table_5x(struct gk20a *g,
282 struct vbios_pstate_header_5x *hdr)
283{
284 struct pstate _pstate, *pstate = &_pstate;
285 struct vbios_pstate_entry_5x *entry;
286 u32 entry_size;
287 u8 i;
288 u8 *p = (u8 *)hdr;
289 int err = 0;
290
291 if ((hdr->header_size != VBIOS_PSTATE_HEADER_5X_SIZE_10) ||
292 (hdr->base_entry_count == 0) ||
293 ((hdr->base_entry_size != VBIOS_PSTATE_BASE_ENTRY_5X_SIZE_2) &&
294 (hdr->base_entry_size != VBIOS_PSTATE_BASE_ENTRY_5X_SIZE_3)) ||
295 (hdr->clock_entry_size != VBIOS_PSTATE_CLOCK_ENTRY_5X_SIZE_6) ||
296 (hdr->clock_entry_count > CLK_SET_INFO_MAX_SIZE))
297 return -EINVAL;
298
299 p += hdr->header_size;
300
301 entry_size = hdr->base_entry_size +
302 hdr->clock_entry_count * hdr->clock_entry_size;
303
304 for (i = 0; i < hdr->base_entry_count; i++, p += entry_size) {
305 entry = (struct vbios_pstate_entry_5x *)p;
306
307 if (entry->pstate_level == VBIOS_PERFLEVEL_SKIP_ENTRY)
308 continue;
309
310 err = parse_pstate_entry_5x(g, hdr, entry, pstate);
311 if (err)
312 goto done;
313
314 pstate = pstate_construct(g, pstate);
315 if (!pstate)
316 goto done;
317
318 err = pstate_insert(g, pstate, i);
319 if (err)
320 goto done;
321 }
322
323done:
324 return err;
325}
326
327static int pstate_sw_setup(struct gk20a *g)
328{
329 struct vbios_pstate_header_5x *hdr = NULL;
330 int err = 0;
331
332 gk20a_dbg_fn("");
333
334 init_waitqueue_head(&g->perf_pmu.pstatesobjs.pstate_notifier_wq);
335 mutex_init(&g->perf_pmu.pstatesobjs.pstate_mutex);
336
337 err = boardobjgrpconstruct_e32(&g->perf_pmu.pstatesobjs.super);
338 if (err) {
339 gk20a_err(dev_from_gk20a(g),
340 "error creating boardobjgrp for pstates, err=%d",
341 err);
342 goto done;
343 }
344
345 if (g->ops.bios.get_perf_table_ptrs) {
346 hdr = (struct vbios_pstate_header_5x *)
347 g->ops.bios.get_perf_table_ptrs(g,
348 g->bios.perf_token, PERFORMANCE_TABLE);
349 }
350
351 if (!hdr) {
352 gk20a_err(dev_from_gk20a(g),
353 "performance table not found");
354 err = -EINVAL;
355 goto done;
356 }
357
358 if (hdr->version != VBIOS_PSTATE_TABLE_VERSION_5X) {
359 gk20a_err(dev_from_gk20a(g),
360 "unknown/unsupported clocks table version=0x%02x",
361 hdr->version);
362 err = -EINVAL;
363 goto done;
364 }
365
366 err = parse_pstate_table_5x(g, hdr);
367done:
368 return err;
369}
370
371struct pstate *pstate_find(struct gk20a *g, u32 num)
372{
373 struct pstates *pstates = &(g->perf_pmu.pstatesobjs);
374 struct pstate *pstate;
375 u8 i;
376
377 gk20a_dbg_info("pstates = %p", pstates);
378
379 BOARDOBJGRP_FOR_EACH(&pstates->super.super,
380 struct pstate *, pstate, i) {
381 gk20a_dbg_info("pstate=%p num=%u (looking for num=%u)",
382 pstate, pstate->num, num);
383 if (pstate->num == num)
384 return pstate;
385 }
386 return NULL;
387}
388
389struct clk_set_info *pstate_get_clk_set_info(struct gk20a *g,
390 u32 pstate_num, enum nv_pmu_clk_clkwhich clkwhich)
391{
392 struct pstate *pstate = pstate_find(g, pstate_num);
393 struct clk_set_info *info;
394 u32 clkidx;
395
396 gk20a_dbg_info("pstate = %p", pstate);
397
398 if (!pstate)
399 return NULL;
400
401 for (clkidx = 0; clkidx < pstate->clklist.num_info; clkidx++) {
402 info = &pstate->clklist.clksetinfo[clkidx];
403 if (info->clkwhich == clkwhich)
404 return info;
405 }
406 return NULL;
407}
diff --git a/drivers/gpu/nvgpu/pstate/pstate.h b/drivers/gpu/nvgpu/pstate/pstate.h
new file mode 100644
index 00000000..af0956e8
--- /dev/null
+++ b/drivers/gpu/nvgpu/pstate/pstate.h
@@ -0,0 +1,63 @@
1/*
2 * general p state infrastructure
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef __PSTATE_H__
16#define __PSTATE_H__
17
18#include "gk20a/gk20a.h"
19#include "clk/clk.h"
20
21#define CTRL_PERF_PSTATE_TYPE_3X 0x3
22
23#define CTRL_PERF_PSTATE_P0 0
24#define CTRL_PERF_PSTATE_P5 5
25#define CTRL_PERF_PSTATE_P8 8
26
27#define CLK_SET_INFO_MAX_SIZE (32)
28
29struct clk_set_info {
30 enum nv_pmu_clk_clkwhich clkwhich;
31 u32 nominal_mhz;
32 u32 min_mhz;
33 u32 max_mhz;
34};
35
36struct clk_set_info_list {
37 u32 num_info;
38 struct clk_set_info clksetinfo[CLK_SET_INFO_MAX_SIZE];
39};
40
41struct pstate {
42 struct boardobj super;
43 u32 num;
44 u8 lpwr_entry_idx;
45 struct clk_set_info_list clklist;
46};
47
48struct pstates {
49 struct boardobjgrp_e32 super;
50 u32 num_levels;
51 wait_queue_head_t pstate_notifier_wq;
52 u32 is_pstate_switch_on;
53 struct mutex pstate_mutex; /* protect is_pstate_switch_on */
54};
55
56int gk20a_init_pstate_support(struct gk20a *g);
57int gk20a_init_pstate_pmu_support(struct gk20a *g);
58
59struct clk_set_info *pstate_get_clk_set_info(struct gk20a *g, u32 pstate_num,
60 enum nv_pmu_clk_clkwhich clkwhich);
61struct pstate *pstate_find(struct gk20a *g, u32 num);
62
63#endif /* __PSTATE_H__ */
diff --git a/drivers/gpu/nvgpu/therm/thrm.c b/drivers/gpu/nvgpu/therm/thrm.c
new file mode 100644
index 00000000..731cf89e
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrm.c
@@ -0,0 +1,45 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "thrm.h"
16#include "thrmpmu.h"
17
18u32 therm_domain_sw_setup(struct gk20a *g)
19{
20 u32 status;
21
22 status = therm_device_sw_setup(g);
23 if (status) {
24 gk20a_err(dev_from_gk20a(g),
25 "error creating boardobjgrp for therm devices, status - 0x%x",
26 status);
27 goto exit;
28 }
29
30 status = therm_channel_sw_setup(g);
31 if (status) {
32 gk20a_err(dev_from_gk20a(g),
33 "error creating boardobjgrp for therm channel, status - 0x%x",
34 status);
35 goto exit;
36 }
37
38exit:
39 return status;
40}
41
42u32 therm_domain_pmu_setup(struct gk20a *g)
43{
44 return therm_send_pmgr_tables_to_pmu(g);
45}
diff --git a/drivers/gpu/nvgpu/therm/thrm.h b/drivers/gpu/nvgpu/therm/thrm.h
new file mode 100644
index 00000000..1db93b49
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrm.h
@@ -0,0 +1,29 @@
1/*
2 * general thermal table structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _THRM_H_
16#define _THRM_H_
17
18#include "thrmdev.h"
19#include "thrmchannel.h"
20
21struct therm_pmupstate {
22 struct therm_devices therm_deviceobjs;
23 struct therm_channels therm_channelobjs;
24};
25
26u32 therm_domain_sw_setup(struct gk20a *g);
27u32 therm_domain_pmu_setup(struct gk20a *g);
28
29#endif
diff --git a/drivers/gpu/nvgpu/therm/thrmchannel.c b/drivers/gpu/nvgpu/therm/thrmchannel.c
new file mode 100644
index 00000000..b5a7dfd2
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmchannel.c
@@ -0,0 +1,246 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "thrmchannel.h"
16#include "include/bios.h"
17#include "boardobj/boardobjgrp.h"
18#include "boardobj/boardobjgrp_e32.h"
19#include "pmuif/gpmuifboardobj.h"
20#include "pmuif/gpmuifthermsensor.h"
21#include "gm206/bios_gm206.h"
22#include "gk20a/pmu_gk20a.h"
23
24static u32 _therm_channel_pmudatainit_device(struct gk20a *g,
25 struct boardobj *board_obj_ptr,
26 struct nv_pmu_boardobj *ppmudata)
27{
28 u32 status = 0;
29 struct therm_channel *pchannel;
30 struct therm_channel_device *ptherm_channel;
31 struct nv_pmu_therm_therm_channel_device_boardobj_set *pset;
32
33 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
34 if (status) {
35 gk20a_err(dev_from_gk20a(g),
36 "error updating pmu boardobjgrp for therm channel 0x%x",
37 status);
38 status = -ENOMEM;
39 goto done;
40 }
41
42 pchannel = (struct therm_channel *)board_obj_ptr;
43 pset = (struct nv_pmu_therm_therm_channel_device_boardobj_set *)ppmudata;
44 ptherm_channel = (struct therm_channel_device *)board_obj_ptr;
45
46 pset->super.scaling = pchannel->scaling;
47 pset->super.offset = pchannel->offset;
48 pset->super.temp_min = pchannel->temp_min;
49 pset->super.temp_max = pchannel->temp_max;
50
51 pset->therm_dev_idx = ptherm_channel->therm_dev_idx;
52 pset->therm_dev_prov_idx = ptherm_channel->therm_dev_prov_idx;
53
54done:
55 return status;
56}
57static struct boardobj *construct_channel_device(struct gk20a *g,
58 void *pargs, u16 pargs_size, u8 type)
59{
60 struct boardobj *board_obj_ptr = NULL;
61 struct therm_channel *pchannel;
62 struct therm_channel_device *pchannel_device;
63 u32 status;
64 struct therm_channel_device *therm_device = (struct therm_channel_device*)pargs;
65
66 status = boardobj_construct_super(g, &board_obj_ptr,
67 pargs_size, pargs);
68 if (status)
69 return NULL;
70
71 /* Set Super class interfaces */
72 board_obj_ptr->pmudatainit = _therm_channel_pmudatainit_device;
73
74 pchannel = (struct therm_channel *)board_obj_ptr;
75 pchannel_device = (struct therm_channel_device *)board_obj_ptr;
76
77 g->ops.therm.get_internal_sensor_limits(&pchannel->temp_max,
78 &pchannel->temp_min);
79 pchannel->scaling = (1 << 8);
80 pchannel->offset = 0;
81
82 pchannel_device->therm_dev_idx = therm_device->therm_dev_idx;
83 pchannel_device->therm_dev_prov_idx = therm_device->therm_dev_prov_idx;
84
85 gk20a_dbg_info(" Done");
86
87 return board_obj_ptr;
88}
89
90static u32 _therm_channel_pmudata_instget(struct gk20a *g,
91 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
92 struct nv_pmu_boardobj **ppboardobjpmudata,
93 u8 idx)
94{
95 struct nv_pmu_therm_therm_channel_boardobj_grp_set *pgrp_set =
96 (struct nv_pmu_therm_therm_channel_boardobj_grp_set *)
97 pmuboardobjgrp;
98
99 gk20a_dbg_info("");
100
101 /*check whether pmuboardobjgrp has a valid boardobj in index*/
102 if (((u32)BIT(idx) &
103 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
104 return -EINVAL;
105
106 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
107 &pgrp_set->objects[idx].data.board_obj;
108
109 gk20a_dbg_info(" Done");
110
111 return 0;
112}
113
114static u32 devinit_get_therm_channel_table(struct gk20a *g,
115 struct therm_channels *pthermchannelobjs)
116{
117 u32 status = 0;
118 u8 *therm_channel_table_ptr = NULL;
119 u8 *curr_therm_channel_table_ptr = NULL;
120 struct boardobj *boardobj;
121 struct therm_channel_1x_header therm_channel_table_header = { 0 };
122 struct therm_channel_1x_entry *therm_channel_table_entry = NULL;
123 u32 index;
124 u32 obj_index = 0;
125 u16 therm_channel_size = 0;
126 union {
127 struct boardobj boardobj;
128 struct therm_channel therm_channel;
129 struct therm_channel_device device;
130 } therm_channel_data;
131
132 gk20a_dbg_info("");
133
134 if (g->ops.bios.get_perf_table_ptrs) {
135 therm_channel_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
136 g->bios.perf_token, THERMAL_CHANNEL_TABLE);
137 if (therm_channel_table_ptr == NULL) {
138 status = -EINVAL;
139 goto done;
140 }
141 }
142
143 memcpy(&therm_channel_table_header, therm_channel_table_ptr,
144 VBIOS_THERM_CHANNEL_1X_HEADER_SIZE_09);
145
146 if (therm_channel_table_header.version !=
147 VBIOS_THERM_CHANNEL_VERSION_1X) {
148 status = -EINVAL;
149 goto done;
150 }
151
152 if (therm_channel_table_header.header_size <
153 VBIOS_THERM_CHANNEL_1X_HEADER_SIZE_09) {
154 status = -EINVAL;
155 goto done;
156 }
157
158 curr_therm_channel_table_ptr = (therm_channel_table_ptr +
159 VBIOS_THERM_CHANNEL_1X_HEADER_SIZE_09);
160
161 for (index = 0; index < therm_channel_table_header.num_table_entries;
162 index++) {
163 therm_channel_table_entry = (struct therm_channel_1x_entry *)
164 (curr_therm_channel_table_ptr +
165 (therm_channel_table_header.table_entry_size * index));
166
167 if (therm_channel_table_entry->class_id !=
168 NV_VBIOS_THERM_CHANNEL_1X_ENTRY_CLASS_DEVICE) {
169 continue;
170 }
171
172 therm_channel_data.device.therm_dev_idx = therm_channel_table_entry->param0;
173 therm_channel_data.device.therm_dev_prov_idx = therm_channel_table_entry->param1;
174
175 therm_channel_size = sizeof(struct therm_channel_device);
176 therm_channel_data.boardobj.type = CTRL_THERMAL_THERM_CHANNEL_CLASS_DEVICE;
177
178 boardobj = construct_channel_device(g, &therm_channel_data,
179 therm_channel_size, therm_channel_data.boardobj.type);
180
181 if (!boardobj) {
182 gk20a_err(dev_from_gk20a(g),
183 "unable to create thermal device for %d type %d",
184 index, therm_channel_data.boardobj.type);
185 status = -EINVAL;
186 goto done;
187 }
188
189 status = boardobjgrp_objinsert(&pthermchannelobjs->super.super,
190 boardobj, obj_index);
191
192 if (status) {
193 gk20a_err(dev_from_gk20a(g),
194 "unable to insert thermal device boardobj for %d", index);
195 status = -EINVAL;
196 goto done;
197 }
198
199 ++obj_index;
200 }
201
202done:
203 gk20a_dbg_info(" done status %x", status);
204 return status;
205}
206
207u32 therm_channel_sw_setup(struct gk20a *g)
208{
209 u32 status;
210 struct boardobjgrp *pboardobjgrp = NULL;
211 struct therm_channels *pthermchannelobjs;
212
213 /* Construct the Super Class and override the Interfaces */
214 status = boardobjgrpconstruct_e32(&g->therm_pmu.therm_channelobjs.super);
215 if (status) {
216 gk20a_err(dev_from_gk20a(g),
217 "error creating boardobjgrp for therm devices, status - 0x%x",
218 status);
219 goto done;
220 }
221
222 pboardobjgrp = &g->therm_pmu.therm_channelobjs.super.super;
223 pthermchannelobjs = &(g->therm_pmu.therm_channelobjs);
224
225 /* Override the Interfaces */
226 pboardobjgrp->pmudatainstget = _therm_channel_pmudata_instget;
227
228 status = devinit_get_therm_channel_table(g, pthermchannelobjs);
229 if (status)
230 goto done;
231
232 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, THERM, THERM_CHANNEL);
233
234 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
235 therm, THERM, therm_channel, THERM_CHANNEL);
236 if (status) {
237 gk20a_err(dev_from_gk20a(g),
238 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
239 status);
240 goto done;
241 }
242
243done:
244 gk20a_dbg_info(" done status %x", status);
245 return status;
246}
diff --git a/drivers/gpu/nvgpu/therm/thrmchannel.h b/drivers/gpu/nvgpu/therm/thrmchannel.h
new file mode 100644
index 00000000..4b9d19da
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmchannel.h
@@ -0,0 +1,42 @@
1/*
2 * general thermal device structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _THRMCHANNEL_H_
16#define _THRMCHANNEL_H_
17
18#include "boardobj/boardobj.h"
19#include "boardobj/boardobjgrp.h"
20#include "ctrl/ctrltherm.h"
21
22struct therm_channel {
23 struct boardobj super;
24 s16 scaling;
25 s16 offset;
26 s32 temp_min;
27 s32 temp_max;
28};
29
30struct therm_channels {
31 struct boardobjgrp_e32 super;
32};
33
34struct therm_channel_device {
35 struct therm_channel super;
36 u8 therm_dev_idx;
37 u8 therm_dev_prov_idx;
38};
39
40u32 therm_channel_sw_setup(struct gk20a *g);
41
42#endif
diff --git a/drivers/gpu/nvgpu/therm/thrmdev.c b/drivers/gpu/nvgpu/therm/thrmdev.c
new file mode 100644
index 00000000..83ac9739
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmdev.c
@@ -0,0 +1,193 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "thrmdev.h"
16#include "include/bios.h"
17#include "boardobj/boardobjgrp.h"
18#include "boardobj/boardobjgrp_e32.h"
19#include "pmuif/gpmuifboardobj.h"
20#include "pmuif/gpmuifthermsensor.h"
21#include "gm206/bios_gm206.h"
22#include "gk20a/pmu_gk20a.h"
23#include "ctrl/ctrltherm.h"
24
25static struct boardobj *construct_therm_device(struct gk20a *g,
26 void *pargs, u16 pargs_size, u8 type)
27{
28 struct boardobj *board_obj_ptr = NULL;
29 u32 status;
30
31 status = boardobj_construct_super(g, &board_obj_ptr,
32 pargs_size, pargs);
33 if (status)
34 return NULL;
35
36 gk20a_dbg_info(" Done");
37
38 return board_obj_ptr;
39}
40
41static u32 _therm_device_pmudata_instget(struct gk20a *g,
42 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
43 struct nv_pmu_boardobj **ppboardobjpmudata,
44 u8 idx)
45{
46 struct nv_pmu_therm_therm_device_boardobj_grp_set *pgrp_set =
47 (struct nv_pmu_therm_therm_device_boardobj_grp_set *)
48 pmuboardobjgrp;
49
50 gk20a_dbg_info("");
51
52 /*check whether pmuboardobjgrp has a valid boardobj in index*/
53 if (((u32)BIT(idx) &
54 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
55 return -EINVAL;
56
57 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
58 &pgrp_set->objects[idx].data;
59
60 gk20a_dbg_info(" Done");
61
62 return 0;
63}
64
65static u32 devinit_get_therm_device_table(struct gk20a *g,
66 struct therm_devices *pthermdeviceobjs)
67{
68 u32 status = 0;
69 u8 *therm_device_table_ptr = NULL;
70 u8 *curr_therm_device_table_ptr = NULL;
71 struct boardobj *boardobj;
72 struct therm_device_1x_header therm_device_table_header = { 0 };
73 struct therm_device_1x_entry *therm_device_table_entry = NULL;
74 u32 index;
75 u32 obj_index = 0;
76 u16 therm_device_size = 0;
77 union {
78 struct boardobj boardobj;
79 struct therm_device therm_device;
80 } therm_device_data;
81
82 gk20a_dbg_info("");
83
84 if (g->ops.bios.get_perf_table_ptrs) {
85 therm_device_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
86 g->bios.perf_token, THERMAL_DEVICE_TABLE);
87 if (therm_device_table_ptr == NULL) {
88 status = -EINVAL;
89 goto done;
90 }
91 }
92
93 memcpy(&therm_device_table_header, therm_device_table_ptr,
94 VBIOS_THERM_DEVICE_1X_HEADER_SIZE_04);
95
96 if (therm_device_table_header.version !=
97 VBIOS_THERM_DEVICE_VERSION_1X) {
98 status = -EINVAL;
99 goto done;
100 }
101
102 if (therm_device_table_header.header_size <
103 VBIOS_THERM_DEVICE_1X_HEADER_SIZE_04) {
104 status = -EINVAL;
105 goto done;
106 }
107
108 curr_therm_device_table_ptr = (therm_device_table_ptr +
109 VBIOS_THERM_DEVICE_1X_HEADER_SIZE_04);
110
111 for (index = 0; index < therm_device_table_header.num_table_entries;
112 index++) {
113 therm_device_table_entry = (struct therm_device_1x_entry *)
114 (curr_therm_device_table_ptr +
115 (therm_device_table_header.table_entry_size * index));
116
117 if (therm_device_table_entry->class_id !=
118 NV_VBIOS_THERM_DEVICE_1X_ENTRY_CLASS_GPU) {
119 continue;
120 }
121
122 therm_device_size = sizeof(struct therm_device);
123 therm_device_data.boardobj.type = CTRL_THERMAL_THERM_DEVICE_CLASS_GPU;
124
125 boardobj = construct_therm_device(g, &therm_device_data,
126 therm_device_size, therm_device_data.boardobj.type);
127
128 if (!boardobj) {
129 gk20a_err(dev_from_gk20a(g),
130 "unable to create thermal device for %d type %d",
131 index, therm_device_data.boardobj.type);
132 status = -EINVAL;
133 goto done;
134 }
135
136 status = boardobjgrp_objinsert(&pthermdeviceobjs->super.super,
137 boardobj, obj_index);
138
139 if (status) {
140 gk20a_err(dev_from_gk20a(g),
141 "unable to insert thermal device boardobj for %d", index);
142 status = -EINVAL;
143 goto done;
144 }
145
146 ++obj_index;
147 }
148
149done:
150 gk20a_dbg_info(" done status %x", status);
151 return status;
152}
153
154u32 therm_device_sw_setup(struct gk20a *g)
155{
156 u32 status;
157 struct boardobjgrp *pboardobjgrp = NULL;
158 struct therm_devices *pthermdeviceobjs;
159
160 /* Construct the Super Class and override the Interfaces */
161 status = boardobjgrpconstruct_e32(&g->therm_pmu.therm_deviceobjs.super);
162 if (status) {
163 gk20a_err(dev_from_gk20a(g),
164 "error creating boardobjgrp for therm devices, status - 0x%x",
165 status);
166 goto done;
167 }
168
169 pboardobjgrp = &g->therm_pmu.therm_deviceobjs.super.super;
170 pthermdeviceobjs = &(g->therm_pmu.therm_deviceobjs);
171
172 /* Override the Interfaces */
173 pboardobjgrp->pmudatainstget = _therm_device_pmudata_instget;
174
175 status = devinit_get_therm_device_table(g, pthermdeviceobjs);
176 if (status)
177 goto done;
178
179 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, THERM, THERM_DEVICE);
180
181 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
182 therm, THERM, therm_device, THERM_DEVICE);
183 if (status) {
184 gk20a_err(dev_from_gk20a(g),
185 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
186 status);
187 goto done;
188 }
189
190done:
191 gk20a_dbg_info(" done status %x", status);
192 return status;
193}
diff --git a/drivers/gpu/nvgpu/therm/thrmdev.h b/drivers/gpu/nvgpu/therm/thrmdev.h
new file mode 100644
index 00000000..35be47c0
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmdev.h
@@ -0,0 +1,31 @@
1/*
2 * general thermal device structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _THRMDEV_H_
16#define _THRMDEV_H_
17
18#include "boardobj/boardobj.h"
19#include "boardobj/boardobjgrp.h"
20
21struct therm_devices {
22 struct boardobjgrp_e32 super;
23};
24
25struct therm_device {
26 struct therm_devices super;
27};
28
29u32 therm_device_sw_setup(struct gk20a *g);
30
31#endif
diff --git a/drivers/gpu/nvgpu/therm/thrmpmu.c b/drivers/gpu/nvgpu/therm/thrmpmu.c
new file mode 100644
index 00000000..0d0a4b3a
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmpmu.c
@@ -0,0 +1,142 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "include/bios.h"
16#include "boardobj/boardobjgrp.h"
17#include "boardobj/boardobjgrp_e32.h"
18#include "pmuif/gpmuifboardobj.h"
19#include "thrmpmu.h"
20#include "pmuif/gpmuiftherm.h"
21
22struct therm_pmucmdhandler_params {
23 struct nv_pmu_therm_rpc *prpccall;
24 u32 success;
25};
26
27static void therm_pmucmdhandler(struct gk20a *g, struct pmu_msg *msg,
28 void *param, u32 handle, u32 status)
29{
30 struct therm_pmucmdhandler_params *phandlerparams =
31 (struct therm_pmucmdhandler_params *)param;
32
33 if (msg->msg.therm.msg_type != NV_PMU_THERM_MSG_ID_RPC) {
34 gk20a_err(dev_from_gk20a(g),
35 "unknow msg %x",
36 msg->msg.pmgr.msg_type);
37 return;
38 }
39
40 if (!phandlerparams->prpccall->b_supported)
41 gk20a_err(dev_from_gk20a(g),
42 "RPC msg %x failed",
43 msg->msg.pmgr.msg_type);
44 else
45 phandlerparams->success = 1;
46}
47
48u32 therm_send_pmgr_tables_to_pmu(struct gk20a *g)
49{
50 u32 status = 0;
51 struct boardobjgrp *pboardobjgrp = NULL;
52
53 if (!BOARDOBJGRP_IS_EMPTY(&g->therm_pmu.therm_deviceobjs.super.super)) {
54 pboardobjgrp = &g->therm_pmu.therm_deviceobjs.super.super;
55 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
56 if (status) {
57 gk20a_err(dev_from_gk20a(g),
58 "therm_send_pmgr_tables_to_pmu - therm_device failed %x",
59 status);
60 goto exit;
61 }
62 }
63
64 if (!BOARDOBJGRP_IS_EMPTY(
65 &g->therm_pmu.therm_channelobjs.super.super)) {
66 pboardobjgrp = &g->therm_pmu.therm_channelobjs.super.super;
67 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
68 if (status) {
69 gk20a_err(dev_from_gk20a(g),
70 "therm_send_pmgr_tables_to_pmu - therm_channel failed %x",
71 status);
72 goto exit;
73 }
74 }
75
76exit:
77 return status;
78}
79
80u32 therm_set_warn_temp_limit(struct gk20a *g)
81{
82 u32 status;
83 u32 seqdesc = 0;
84 struct pmu_cmd cmd = { {0} };
85 struct pmu_msg msg = { {0} };
86 struct pmu_payload payload = { {0} };
87 struct nv_pmu_therm_rpc rpccall = {0};
88 struct therm_pmucmdhandler_params handlerparams = {0};
89
90 rpccall.function = NV_PMU_THERM_RPC_ID_SLCT_EVENT_TEMP_TH_SET;
91 rpccall.params.slct_event_temp_th_set.event_id =
92 NV_PMU_THERM_EVENT_THERMAL_1;
93 rpccall.params.slct_event_temp_th_set.temp_threshold = g->curr_warn_temp;
94 rpccall.b_supported = 0;
95
96 cmd.hdr.unit_id = PMU_UNIT_THERM;
97 cmd.hdr.size = ((u32)sizeof(struct nv_pmu_therm_cmd) +
98 (u32)sizeof(struct pmu_hdr));
99 cmd.cmd.therm.cmd_type = NV_PMU_THERM_CMD_ID_RPC;
100
101 msg.hdr.size = sizeof(struct pmu_msg);
102
103 payload.in.buf = (u8 *)&rpccall;
104 payload.in.size = (u32)sizeof(struct nv_pmu_therm_rpc);
105 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
106 payload.in.offset = NV_PMU_THERM_CMD_RPC_ALLOC_OFFSET;
107
108 payload.out.buf = (u8 *)&rpccall;
109 payload.out.size = (u32)sizeof(struct nv_pmu_therm_rpc);
110 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
111 payload.out.offset = NV_PMU_CLK_MSG_RPC_ALLOC_OFFSET;
112
113 /* Setup the handler params to communicate back results.*/
114 handlerparams.success = 0;
115 handlerparams.prpccall = &rpccall;
116
117 status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload,
118 PMU_COMMAND_QUEUE_LPQ,
119 therm_pmucmdhandler,
120 (void *)&handlerparams,
121 &seqdesc, ~0);
122 if (status) {
123 gk20a_err(dev_from_gk20a(g),
124 "unable to post pmgr cmd for unit %x cmd id %x size %x",
125 cmd.hdr.unit_id, cmd.cmd.therm.cmd_type, cmd.hdr.size);
126 goto exit;
127 }
128
129 pmu_wait_message_cond(&g->pmu,
130 gk20a_get_gr_idle_timeout(g),
131 &handlerparams.success, 1);
132
133 if (handlerparams.success == 0) {
134 gk20a_err(dev_from_gk20a(g), "could not process cmd\n");
135 status = -ETIMEDOUT;
136 goto exit;
137 }
138
139exit:
140 return status;
141}
142
diff --git a/drivers/gpu/nvgpu/therm/thrmpmu.h b/drivers/gpu/nvgpu/therm/thrmpmu.h
new file mode 100644
index 00000000..e6f70411
--- /dev/null
+++ b/drivers/gpu/nvgpu/therm/thrmpmu.h
@@ -0,0 +1,22 @@
1/*
2 * general thermal pmu control structures & definitions
3 *
4 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15#ifndef _THRMPMU_H_
16#define _THRMPMU_H_
17
18u32 therm_send_pmgr_tables_to_pmu(struct gk20a *g);
19
20u32 therm_set_warn_temp_limit(struct gk20a *g);
21
22#endif
diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_fifo_gp10b.c b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_fifo_gp10b.c
new file mode 100644
index 00000000..23d945fb
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_fifo_gp10b.c
@@ -0,0 +1,48 @@
1/*
2 * Copyright (c) 2015-2016, 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
14#include "vgpu_fifo_gp10b.h"
15
16static int vgpu_gp10b_fifo_init_engine_info(struct fifo_gk20a *f)
17{
18 struct fifo_engine_info_gk20a *gr_info;
19 struct fifo_engine_info_gk20a *ce_info;
20 const u32 gr_sw_id = ENGINE_GR_GK20A;
21 const u32 ce_sw_id = ENGINE_GRCE_GK20A;
22
23 gk20a_dbg_fn("");
24
25 f->num_engines = 2;
26
27 gr_info = &f->engine_info[0];
28
29 /* FIXME: retrieve this from server */
30 gr_info->runlist_id = 0;
31 gr_info->engine_enum = gr_sw_id;
32 f->active_engines_list[0] = 0;
33
34 ce_info = &f->engine_info[1];
35 ce_info->runlist_id = 0;
36 ce_info->inst_id = 0;
37 ce_info->engine_enum = ce_sw_id;
38 f->active_engines_list[1] = 1;
39
40 return 0;
41}
42
43void vgpu_gp10b_init_fifo_ops(struct gpu_ops *gops)
44{
45 /* syncpoint protection not supported yet */
46 gops->fifo.init_engine_info = vgpu_gp10b_fifo_init_engine_info;
47 gops->fifo.resetup_ramfc = NULL;
48}
diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_fifo_gp10b.h b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_fifo_gp10b.h
new file mode 100644
index 00000000..4ede0b6d
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_fifo_gp10b.h
@@ -0,0 +1,21 @@
1/*
2 * Copyright (c) 2015, 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
14#ifndef __VGPU_FIFO_GP10B_H__
15#define __VGPU_FIFO_GP10B_H__
16
17#include "gk20a/gk20a.h"
18
19void vgpu_gp10b_init_fifo_ops(struct gpu_ops *gops);
20
21#endif
diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.c b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.c
new file mode 100644
index 00000000..85dc8c22
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.c
@@ -0,0 +1,321 @@
1/*
2 * Copyright (c) 2015-2016, 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
14#include "vgpu/vgpu.h"
15#include "vgpu_gr_gp10b.h"
16#include "vgpu/gm20b/vgpu_gr_gm20b.h"
17
18#include "gp10b/hw_gr_gp10b.h"
19
20static void vgpu_gr_gp10b_free_gr_ctx(struct gk20a *g, struct vm_gk20a *vm,
21 struct gr_ctx_desc *gr_ctx)
22{
23 struct tegra_vgpu_cmd_msg msg = {0};
24 struct tegra_vgpu_gr_ctx_params *p = &msg.params.gr_ctx;
25 int err;
26
27 gk20a_dbg_fn("");
28
29 if (!gr_ctx || !gr_ctx->mem.gpu_va)
30 return;
31
32 msg.cmd = TEGRA_VGPU_CMD_GR_CTX_FREE;
33 msg.handle = vgpu_get_handle(g);
34 p->gr_ctx_handle = gr_ctx->virt_ctx;
35 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
36 WARN_ON(err || msg.ret);
37
38 gk20a_vm_free_va(vm, gr_ctx->mem.gpu_va, gr_ctx->mem.size,
39 gmmu_page_size_kernel);
40
41 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.pagepool_ctxsw_buffer);
42 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.betacb_ctxsw_buffer);
43 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.spill_ctxsw_buffer);
44 gk20a_gmmu_unmap_free(vm, &gr_ctx->t18x.preempt_ctxsw_buffer);
45
46 kfree(gr_ctx);
47}
48
49static int vgpu_gr_gp10b_alloc_gr_ctx(struct gk20a *g,
50 struct gr_ctx_desc **__gr_ctx,
51 struct vm_gk20a *vm,
52 u32 class,
53 u32 flags)
54{
55 struct gr_ctx_desc *gr_ctx;
56 u32 graphics_preempt_mode = 0;
57 u32 compute_preempt_mode = 0;
58 int err;
59
60 gk20a_dbg_fn("");
61
62 err = vgpu_gr_alloc_gr_ctx(g, __gr_ctx, vm, class, flags);
63 if (err)
64 return err;
65
66 gr_ctx = *__gr_ctx;
67
68 if (flags & NVGPU_ALLOC_OBJ_FLAGS_GFXP)
69 graphics_preempt_mode = NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP;
70 if (flags & NVGPU_ALLOC_OBJ_FLAGS_CILP)
71 compute_preempt_mode = NVGPU_COMPUTE_PREEMPTION_MODE_CILP;
72
73 if (graphics_preempt_mode || compute_preempt_mode) {
74 if (g->ops.gr.set_ctxsw_preemption_mode) {
75 err = g->ops.gr.set_ctxsw_preemption_mode(g, gr_ctx, vm,
76 class, graphics_preempt_mode, compute_preempt_mode);
77 if (err) {
78 gk20a_err(dev_from_gk20a(g),
79 "set_ctxsw_preemption_mode failed");
80 goto fail;
81 }
82 } else {
83 err = -ENOSYS;
84 goto fail;
85 }
86 }
87
88 gk20a_dbg_fn("done");
89 return err;
90
91fail:
92 vgpu_gr_gp10b_free_gr_ctx(g, vm, gr_ctx);
93 return err;
94}
95
96static int vgpu_gr_gp10b_set_ctxsw_preemption_mode(struct gk20a *g,
97 struct gr_ctx_desc *gr_ctx,
98 struct vm_gk20a *vm, u32 class,
99 u32 graphics_preempt_mode,
100 u32 compute_preempt_mode)
101{
102 struct tegra_vgpu_cmd_msg msg = {};
103 struct tegra_vgpu_gr_bind_ctxsw_buffers_params *p =
104 &msg.params.gr_bind_ctxsw_buffers;
105 int err = 0;
106
107 WARN_ON(TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_MAX !=
108 TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_LAST);
109
110 if (class == PASCAL_A && g->gr.t18x.ctx_vars.force_preemption_gfxp)
111 graphics_preempt_mode = NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP;
112
113 if (class == PASCAL_COMPUTE_A &&
114 g->gr.t18x.ctx_vars.force_preemption_cilp)
115 compute_preempt_mode = NVGPU_COMPUTE_PREEMPTION_MODE_CILP;
116
117 /* check for invalid combinations */
118 if ((graphics_preempt_mode == 0) && (compute_preempt_mode == 0))
119 return -EINVAL;
120
121 if ((graphics_preempt_mode == NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP) &&
122 (compute_preempt_mode == NVGPU_COMPUTE_PREEMPTION_MODE_CILP))
123 return -EINVAL;
124
125 /* set preemption modes */
126 switch (graphics_preempt_mode) {
127 case NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP:
128 {
129 u32 spill_size =
130 gr_gpc0_swdx_rm_spill_buffer_size_256b_default_v() *
131 gr_gpc0_swdx_rm_spill_buffer_size_256b_byte_granularity_v();
132 u32 pagepool_size = g->ops.gr.pagepool_default_size(g) *
133 gr_scc_pagepool_total_pages_byte_granularity_v();
134 u32 betacb_size = g->gr.attrib_cb_default_size +
135 (gr_gpc0_ppc0_cbm_beta_cb_size_v_gfxp_v() -
136 gr_gpc0_ppc0_cbm_beta_cb_size_v_default_v());
137 u32 attrib_cb_size = (betacb_size + g->gr.alpha_cb_size) *
138 gr_gpc0_ppc0_cbm_beta_cb_size_v_granularity_v() *
139 g->gr.max_tpc_count;
140 struct mem_desc *desc;
141
142 attrib_cb_size = ALIGN(attrib_cb_size, 128);
143
144 gk20a_dbg_info("gfxp context preempt size=%d",
145 g->gr.t18x.ctx_vars.preempt_image_size);
146 gk20a_dbg_info("gfxp context spill size=%d", spill_size);
147 gk20a_dbg_info("gfxp context pagepool size=%d", pagepool_size);
148 gk20a_dbg_info("gfxp context attrib cb size=%d",
149 attrib_cb_size);
150
151 err = gr_gp10b_alloc_buffer(vm,
152 g->gr.t18x.ctx_vars.preempt_image_size,
153 &gr_ctx->t18x.preempt_ctxsw_buffer);
154 if (err) {
155 err = -ENOMEM;
156 goto fail;
157 }
158 desc = &gr_ctx->t18x.preempt_ctxsw_buffer;
159 p->gpu_va[TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_MAIN] = desc->gpu_va;
160 p->size[TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_MAIN] = desc->size;
161
162 err = gr_gp10b_alloc_buffer(vm,
163 spill_size,
164 &gr_ctx->t18x.spill_ctxsw_buffer);
165 if (err) {
166 err = -ENOMEM;
167 goto fail;
168 }
169 desc = &gr_ctx->t18x.spill_ctxsw_buffer;
170 p->gpu_va[TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_SPILL] = desc->gpu_va;
171 p->size[TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_SPILL] = desc->size;
172
173 err = gr_gp10b_alloc_buffer(vm,
174 pagepool_size,
175 &gr_ctx->t18x.pagepool_ctxsw_buffer);
176 if (err) {
177 err = -ENOMEM;
178 goto fail;
179 }
180 desc = &gr_ctx->t18x.pagepool_ctxsw_buffer;
181 p->gpu_va[TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_PAGEPOOL] =
182 desc->gpu_va;
183 p->size[TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_PAGEPOOL] = desc->size;
184
185 err = gr_gp10b_alloc_buffer(vm,
186 attrib_cb_size,
187 &gr_ctx->t18x.betacb_ctxsw_buffer);
188 if (err) {
189 err = -ENOMEM;
190 goto fail;
191 }
192 desc = &gr_ctx->t18x.betacb_ctxsw_buffer;
193 p->gpu_va[TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_BETACB] =
194 desc->gpu_va;
195 p->size[TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_BETACB] = desc->size;
196
197 gr_ctx->graphics_preempt_mode = NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP;
198 p->mode = TEGRA_VGPU_GR_CTXSW_PREEMPTION_MODE_GFX_GFXP;
199 break;
200 }
201 case NVGPU_GRAPHICS_PREEMPTION_MODE_WFI:
202 gr_ctx->graphics_preempt_mode = graphics_preempt_mode;
203 break;
204
205 default:
206 break;
207 }
208
209 if (class == PASCAL_COMPUTE_A) {
210 switch (compute_preempt_mode) {
211 case NVGPU_COMPUTE_PREEMPTION_MODE_WFI:
212 gr_ctx->compute_preempt_mode =
213 NVGPU_COMPUTE_PREEMPTION_MODE_WFI;
214 p->mode = TEGRA_VGPU_GR_CTXSW_PREEMPTION_MODE_WFI;
215 break;
216 case NVGPU_COMPUTE_PREEMPTION_MODE_CTA:
217 gr_ctx->compute_preempt_mode =
218 NVGPU_COMPUTE_PREEMPTION_MODE_CTA;
219 p->mode =
220 TEGRA_VGPU_GR_CTXSW_PREEMPTION_MODE_COMPUTE_CTA;
221 break;
222 case NVGPU_COMPUTE_PREEMPTION_MODE_CILP:
223 gr_ctx->compute_preempt_mode =
224 NVGPU_COMPUTE_PREEMPTION_MODE_CILP;
225 p->mode =
226 TEGRA_VGPU_GR_CTXSW_PREEMPTION_MODE_COMPUTE_CILP;
227 break;
228 default:
229 break;
230 }
231 }
232
233 if (gr_ctx->graphics_preempt_mode || gr_ctx->compute_preempt_mode) {
234 msg.cmd = TEGRA_VGPU_CMD_CHANNEL_BIND_GR_CTXSW_BUFFERS;
235 msg.handle = vgpu_get_handle(g);
236 p->gr_ctx_handle = gr_ctx->virt_ctx;
237 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
238 if (err || msg.ret) {
239 err = -ENOMEM;
240 goto fail;
241 }
242 }
243
244 return err;
245
246fail:
247 gk20a_err(dev_from_gk20a(g), "%s failed %d", __func__, err);
248 return err;
249}
250
251static int vgpu_gr_gp10b_set_preemption_mode(struct channel_gk20a *ch,
252 u32 graphics_preempt_mode,
253 u32 compute_preempt_mode)
254{
255 struct gr_ctx_desc *gr_ctx = ch->ch_ctx.gr_ctx;
256 struct gk20a *g = ch->g;
257 struct tsg_gk20a *tsg;
258 struct vm_gk20a *vm;
259 u32 class;
260 int err;
261
262 class = ch->obj_class;
263 if (!class)
264 return -EINVAL;
265
266 /* preemption already set ? */
267 if (gr_ctx->graphics_preempt_mode || gr_ctx->compute_preempt_mode)
268 return -EINVAL;
269
270 if (gk20a_is_channel_marked_as_tsg(ch)) {
271 tsg = &g->fifo.tsg[ch->tsgid];
272 vm = tsg->vm;
273 } else {
274 vm = ch->vm;
275 }
276
277 if (g->ops.gr.set_ctxsw_preemption_mode) {
278 err = g->ops.gr.set_ctxsw_preemption_mode(g, gr_ctx, vm, class,
279 graphics_preempt_mode,
280 compute_preempt_mode);
281 if (err) {
282 gk20a_err(dev_from_gk20a(g),
283 "set_ctxsw_preemption_mode failed");
284 return err;
285 }
286 } else {
287 err = -ENOSYS;
288 }
289
290 return err;
291}
292
293static int vgpu_gr_gp10b_init_ctx_state(struct gk20a *g)
294{
295 int err;
296
297 gk20a_dbg_fn("");
298
299 err = vgpu_gr_init_ctx_state(g);
300 if (err)
301 return err;
302
303 vgpu_get_attribute(vgpu_get_handle(g),
304 TEGRA_VGPU_ATTRIB_PREEMPT_CTX_SIZE,
305 &g->gr.t18x.ctx_vars.preempt_image_size);
306 if (!g->gr.t18x.ctx_vars.preempt_image_size)
307 return -ENXIO;
308
309 return 0;
310}
311
312void vgpu_gp10b_init_gr_ops(struct gpu_ops *gops)
313{
314 vgpu_gm20b_init_gr_ops(gops);
315 gops->gr.alloc_gr_ctx = vgpu_gr_gp10b_alloc_gr_ctx;
316 gops->gr.free_gr_ctx = vgpu_gr_gp10b_free_gr_ctx;
317 gops->gr.init_ctx_state = vgpu_gr_gp10b_init_ctx_state;
318 gops->gr.set_preemption_mode = vgpu_gr_gp10b_set_preemption_mode;
319 gops->gr.set_ctxsw_preemption_mode =
320 vgpu_gr_gp10b_set_ctxsw_preemption_mode;
321}
diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.h b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.h
new file mode 100644
index 00000000..b3be49a7
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_gr_gp10b.h
@@ -0,0 +1,21 @@
1/*
2 * Copyright (c) 2015, 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
14#ifndef __VGPU_GR_GP10B_H__
15#define __VGPU_GR_GP10B_H__
16
17#include "gk20a/gk20a.h"
18
19void vgpu_gp10b_init_gr_ops(struct gpu_ops *gops);
20
21#endif
diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c
new file mode 100644
index 00000000..b665a8dd
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_hal_gp10b.c
@@ -0,0 +1,36 @@
1/*
2 * Copyright (c) 2015, 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
14#include "vgpu/vgpu.h"
15#include "gp10b/hal_gp10b.h"
16#include "vgpu_gr_gp10b.h"
17#include "vgpu_fifo_gp10b.h"
18#include "vgpu_mm_gp10b.h"
19#include "nvgpu_gpuid_t18x.h"
20
21int vgpu_gp10b_init_hal(struct gk20a *g)
22{
23 int err;
24
25 gk20a_dbg_fn("");
26
27 err = gp10b_init_hal(g);
28 if (err)
29 return err;
30
31 vgpu_init_hal_common(g);
32 vgpu_gp10b_init_gr_ops(&g->ops);
33 vgpu_gp10b_init_fifo_ops(&g->ops);
34 vgpu_gp10b_init_mm_ops(&g->ops);
35 return 0;
36}
diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c
new file mode 100644
index 00000000..66fda2d9
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.c
@@ -0,0 +1,188 @@
1/*
2 * Virtualized GPU Memory Management
3 *
4 * Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16#include <linux/dma-mapping.h>
17#include "vgpu/vgpu.h"
18#include "vgpu_mm_gp10b.h"
19#include "gk20a/semaphore_gk20a.h"
20#include "gk20a/mm_gk20a.h"
21
22static int vgpu_gp10b_init_mm_setup_hw(struct gk20a *g)
23{
24 g->mm.bypass_smmu = true;
25 g->mm.disable_bigpage = true;
26 return 0;
27}
28
29static inline int add_mem_desc(struct tegra_vgpu_mem_desc *mem_desc,
30 u64 addr, u64 size, size_t *oob_size)
31{
32 if (*oob_size < sizeof(*mem_desc))
33 return -ENOMEM;
34
35 mem_desc->addr = addr;
36 mem_desc->length = size;
37 *oob_size -= sizeof(*mem_desc);
38 return 0;
39}
40
41static u64 vgpu_gp10b_locked_gmmu_map(struct vm_gk20a *vm,
42 u64 map_offset,
43 struct sg_table *sgt,
44 u64 buffer_offset,
45 u64 size,
46 int pgsz_idx,
47 u8 kind_v,
48 u32 ctag_offset,
49 u32 flags,
50 int rw_flag,
51 bool clear_ctags,
52 bool sparse,
53 bool priv,
54 struct vm_gk20a_mapping_batch *batch,
55 enum gk20a_aperture aperture)
56{
57 int err = 0;
58 struct device *d = dev_from_vm(vm);
59 struct gk20a *g = gk20a_from_vm(vm);
60 struct tegra_vgpu_cmd_msg msg;
61 struct tegra_vgpu_as_map_ex_params *p = &msg.params.as_map_ex;
62 struct tegra_vgpu_mem_desc *mem_desc;
63 u32 page_size = vm->gmmu_page_sizes[pgsz_idx];
64 u64 space_to_skip = buffer_offset;
65 u64 buffer_size = 0;
66 u32 mem_desc_count = 0;
67 struct scatterlist *sgl;
68 void *handle = NULL;
69 size_t oob_size;
70 u8 prot;
71
72 gk20a_dbg_fn("");
73
74 /* FIXME: add support for sparse mappings */
75
76 if (WARN_ON(!sgt) || WARN_ON(!g->mm.bypass_smmu))
77 return 0;
78
79 if (space_to_skip & (page_size - 1))
80 return 0;
81
82 /* Allocate (or validate when map_offset != 0) the virtual address. */
83 if (!map_offset) {
84 map_offset = gk20a_vm_alloc_va(vm, size, pgsz_idx);
85 if (!map_offset) {
86 gk20a_err(d, "failed to allocate va space");
87 err = -ENOMEM;
88 goto fail;
89 }
90 }
91
92 handle = tegra_gr_comm_oob_get_ptr(TEGRA_GR_COMM_CTX_CLIENT,
93 tegra_gr_comm_get_server_vmid(),
94 TEGRA_VGPU_QUEUE_CMD,
95 (void **)&mem_desc, &oob_size);
96 if (!handle) {
97 err = -EINVAL;
98 goto fail;
99 }
100
101 sgl = sgt->sgl;
102 while (space_to_skip && sgl &&
103 (space_to_skip + page_size > sgl->length)) {
104 space_to_skip -= sgl->length;
105 sgl = sg_next(sgl);
106 }
107 WARN_ON(!sgl);
108
109 if (add_mem_desc(&mem_desc[mem_desc_count++],
110 sg_phys(sgl) + space_to_skip,
111 sgl->length - space_to_skip,
112 &oob_size)) {
113 err = -ENOMEM;
114 goto fail;
115 }
116 buffer_size += sgl->length - space_to_skip;
117
118 sgl = sg_next(sgl);
119 while (sgl && buffer_size < size) {
120 if (add_mem_desc(&mem_desc[mem_desc_count++], sg_phys(sgl),
121 sgl->length, &oob_size)) {
122 err = -ENOMEM;
123 goto fail;
124 }
125
126 buffer_size += sgl->length;
127 sgl = sg_next(sgl);
128 }
129
130 if (rw_flag == gk20a_mem_flag_read_only)
131 prot = TEGRA_VGPU_MAP_PROT_READ_ONLY;
132 else if (rw_flag == gk20a_mem_flag_write_only)
133 prot = TEGRA_VGPU_MAP_PROT_WRITE_ONLY;
134 else
135 prot = TEGRA_VGPU_MAP_PROT_NONE;
136
137 if (pgsz_idx == gmmu_page_size_kernel) {
138 if (page_size == vm->gmmu_page_sizes[gmmu_page_size_small]) {
139 pgsz_idx = gmmu_page_size_small;
140 } else if (page_size ==
141 vm->gmmu_page_sizes[gmmu_page_size_big]) {
142 pgsz_idx = gmmu_page_size_big;
143 } else {
144 gk20a_err(d, "invalid kernel page size %d\n",
145 page_size);
146 goto fail;
147 }
148 }
149
150 msg.cmd = TEGRA_VGPU_CMD_AS_MAP_EX;
151 msg.handle = vgpu_get_handle(g);
152 p->handle = vm->handle;
153 p->gpu_va = map_offset;
154 p->size = size;
155 p->mem_desc_count = mem_desc_count;
156 p->pgsz_idx = pgsz_idx;
157 p->iova = 0;
158 p->kind = kind_v;
159 p->cacheable =
160 (flags & NVGPU_MAP_BUFFER_FLAGS_CACHEABLE_TRUE) ? 1 : 0;
161 p->prot = prot;
162 p->ctag_offset = ctag_offset;
163 p->clear_ctags = clear_ctags;
164 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
165 if (err || msg.ret)
166 goto fail;
167
168 /* TLB invalidate handled on server side */
169
170 tegra_gr_comm_oob_put_ptr(handle);
171 return map_offset;
172fail:
173 if (handle)
174 tegra_gr_comm_oob_put_ptr(handle);
175 gk20a_err(d, "%s: failed with err=%d\n", __func__, err);
176 return 0;
177}
178
179void vgpu_gp10b_init_mm_ops(struct gpu_ops *gops)
180{
181 gk20a_dbg_fn("");
182
183 gops->mm.gmmu_map = vgpu_gp10b_locked_gmmu_map;
184 gops->mm.init_mm_setup_hw = vgpu_gp10b_init_mm_setup_hw;
185
186 /* FIXME: add support for sparse mappings */
187 gops->mm.support_sparse = NULL;
188}
diff --git a/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.h b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.h
new file mode 100644
index 00000000..5bdc9d1b
--- /dev/null
+++ b/drivers/gpu/nvgpu/vgpu/gp10b/vgpu_mm_gp10b.h
@@ -0,0 +1,21 @@
1/*
2 * Copyright (c) 2015, 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
14#ifndef __VGPU_MM_GP10B_H__
15#define __VGPU_MM_GP10B_H__
16
17#include "gk20a/gk20a.h"
18
19void vgpu_gp10b_init_mm_ops(struct gpu_ops *gops);
20
21#endif
diff --git a/drivers/gpu/nvgpu/volt/volt.h b/drivers/gpu/nvgpu/volt/volt.h
new file mode 100644
index 00000000..0d64c265
--- /dev/null
+++ b/drivers/gpu/nvgpu/volt/volt.h
@@ -0,0 +1,30 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _VOLT_H_
15#define _VOLT_H_
16
17#include "volt_rail.h"
18#include "volt_dev.h"
19#include "volt_policy.h"
20#include "volt_pmu.h"
21
22#define VOLTAGE_DESCRIPTOR_TABLE_ENTRY_INVALID 0xFF
23
24struct obj_volt {
25 struct voltage_rail_metadata volt_rail_metadata;
26 struct voltage_device_metadata volt_dev_metadata;
27 struct voltage_policy_metadata volt_policy_metadata;
28};
29
30#endif /* DRIVERS_GPU_NVGPU_VOLT_VOLT_H_ */
diff --git a/drivers/gpu/nvgpu/volt/volt_dev.c b/drivers/gpu/nvgpu/volt/volt_dev.c
new file mode 100644
index 00000000..3a7ed1b5
--- /dev/null
+++ b/drivers/gpu/nvgpu/volt/volt_dev.c
@@ -0,0 +1,588 @@
1/*
2 * Copyright (c) 2016, 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
14#include <linux/sort.h>
15
16#include "gk20a/gk20a.h"
17#include "include/bios.h"
18#include "boardobj/boardobjgrp.h"
19#include "boardobj/boardobjgrp_e32.h"
20#include "pmuif/gpmuifboardobj.h"
21#include "gm206/bios_gm206.h"
22#include "ctrl/ctrlvolt.h"
23#include "gk20a/pmu_gk20a.h"
24
25#include "pmuif/gpmuifperfvfe.h"
26#include "include/bios.h"
27#include "volt.h"
28
29#define VOLT_DEV_PWM_VOLTAGE_STEPS_INVALID 0
30#define VOLT_DEV_PWM_VOLTAGE_STEPS_DEFAULT 1
31
32u32 volt_device_pmu_data_init_super(struct gk20a *g,
33 struct boardobj *pboard_obj, struct nv_pmu_boardobj *ppmudata)
34{
35 u32 status;
36 struct voltage_device *pdev;
37 struct nv_pmu_volt_volt_device_boardobj_set *pset;
38
39 status = boardobj_pmudatainit_super(g, pboard_obj, ppmudata);
40 if (status)
41 return status;
42
43 pdev = (struct voltage_device *)pboard_obj;
44 pset = (struct nv_pmu_volt_volt_device_boardobj_set *)ppmudata;
45
46 pset->switch_delay_us = pdev->switch_delay_us;
47 pset->voltage_min_uv = pdev->voltage_min_uv;
48 pset->voltage_max_uv = pdev->voltage_max_uv;
49 pset->volt_step_uv = pdev->volt_step_uv;
50
51 return status;
52}
53
54static u32 volt_device_pmu_data_init_pwm(struct gk20a *g,
55 struct boardobj *pboard_obj, struct nv_pmu_boardobj *ppmudata)
56{
57 u32 status = 0;
58 struct voltage_device_pwm *pdev;
59 struct nv_pmu_volt_volt_device_pwm_boardobj_set *pset;
60
61 status = volt_device_pmu_data_init_super(g, pboard_obj, ppmudata);
62 if (status)
63 return status;
64
65 pdev = (struct voltage_device_pwm *)pboard_obj;
66 pset = (struct nv_pmu_volt_volt_device_pwm_boardobj_set *)ppmudata;
67
68 pset->raw_period = pdev->raw_period;
69 pset->voltage_base_uv = pdev->voltage_base_uv;
70 pset->voltage_offset_scale_uv = pdev->voltage_offset_scale_uv;
71 pset->pwm_source = pdev->source;
72
73 return status;
74}
75
76u32 construct_volt_device(struct gk20a *g,
77 struct boardobj **ppboardobj, u16 size, void *pargs)
78{
79 struct voltage_device *ptmp_dev = (struct voltage_device *)pargs;
80 struct voltage_device *pvolt_dev = NULL;
81 u32 status = 0;
82
83 status = boardobj_construct_super(g, ppboardobj, size, pargs);
84 if (status)
85 return status;
86
87 pvolt_dev = (struct voltage_device *)*ppboardobj;
88
89 pvolt_dev->volt_domain = ptmp_dev->volt_domain;
90 pvolt_dev->i2c_dev_idx = ptmp_dev->i2c_dev_idx;
91 pvolt_dev->switch_delay_us = ptmp_dev->switch_delay_us;
92 pvolt_dev->rsvd_0 = VOLTAGE_DESCRIPTOR_TABLE_ENTRY_INVALID;
93 pvolt_dev->rsvd_1 =
94 VOLTAGE_DESCRIPTOR_TABLE_ENTRY_INVALID;
95 pvolt_dev->operation_type = ptmp_dev->operation_type;
96 pvolt_dev->voltage_min_uv = ptmp_dev->voltage_min_uv;
97 pvolt_dev->voltage_max_uv = ptmp_dev->voltage_max_uv;
98
99 pvolt_dev->super.pmudatainit = volt_device_pmu_data_init_super;
100
101 return status;
102}
103
104u32 construct_pwm_volt_device(struct gk20a *g, struct boardobj **ppboardobj,
105 u16 size, void *pargs)
106{
107 struct boardobj *pboard_obj = NULL;
108 struct voltage_device_pwm *ptmp_dev =
109 (struct voltage_device_pwm *)pargs;
110 struct voltage_device_pwm *pdev = NULL;
111 u32 status = 0;
112
113 status = construct_volt_device(g, ppboardobj, size, pargs);
114 if (status)
115 return status;
116
117 pboard_obj = (*ppboardobj);
118 pdev = (struct voltage_device_pwm *)*ppboardobj;
119
120 pboard_obj->pmudatainit = volt_device_pmu_data_init_pwm;
121
122 /* Set VOLTAGE_DEVICE_PWM-specific parameters */
123 pdev->voltage_base_uv = ptmp_dev->voltage_base_uv;
124 pdev->voltage_offset_scale_uv = ptmp_dev->voltage_offset_scale_uv;
125 pdev->source = ptmp_dev->source;
126 pdev->raw_period = ptmp_dev->raw_period;
127
128 return status;
129}
130
131
132struct voltage_device_entry *volt_dev_construct_dev_entry_pwm(struct gk20a *g,
133 u32 voltage_uv, void *pargs)
134{
135 struct voltage_device_pwm_entry *pentry = NULL;
136 struct voltage_device_pwm_entry *ptmp_entry =
137 (struct voltage_device_pwm_entry *)pargs;
138
139 pentry = kzalloc(sizeof(struct voltage_device_pwm_entry), GFP_KERNEL);
140 if (pentry == NULL)
141 return NULL;
142
143 memset(pentry, 0, sizeof(struct voltage_device_pwm_entry));
144
145 pentry->super.voltage_uv = voltage_uv;
146 pentry->duty_cycle = ptmp_entry->duty_cycle;
147
148 return (struct voltage_device_entry *)pentry;
149}
150
151static u8 volt_dev_operation_type_convert(u8 vbios_type)
152{
153 switch (vbios_type) {
154 case NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_OPERATION_TYPE_DEFAULT:
155 return CTRL_VOLT_DEVICE_OPERATION_TYPE_DEFAULT;
156
157 case NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_OPERATION_TYPE_LPWR_STEADY_STATE:
158 return CTRL_VOLT_DEVICE_OPERATION_TYPE_LPWR_STEADY_STATE;
159
160 case NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_OPERATION_TYPE_LPWR_SLEEP_STATE:
161 return CTRL_VOLT_DEVICE_OPERATION_TYPE_LPWR_SLEEP_STATE;
162 }
163
164 return CTRL_VOLT_DEVICE_OPERATION_TYPE_INVALID;
165}
166
167struct voltage_device *volt_volt_device_construct(struct gk20a *g,
168 void *pargs)
169{
170 struct boardobj *pboard_obj = NULL;
171
172 if (BOARDOBJ_GET_TYPE(pargs) == CTRL_VOLT_DEVICE_TYPE_PWM) {
173 u32 status = construct_pwm_volt_device(g, &pboard_obj,
174 sizeof(struct voltage_device_pwm), pargs);
175 if (status) {
176 gk20a_err(dev_from_gk20a(g),
177 " Could not allocate memory for VOLTAGE_DEVICE type (%x).",
178 BOARDOBJ_GET_TYPE(pargs));
179 pboard_obj = NULL;
180 }
181 }
182
183 return (struct voltage_device *)pboard_obj;
184}
185
186static u32 volt_get_voltage_device_table_1x_psv(struct gk20a *g,
187 struct vbios_voltage_device_table_1x_entry *p_bios_entry,
188 struct voltage_device_metadata *p_Volt_Device_Meta_Data,
189 u8 entry_Idx)
190{
191 u32 status = 0;
192 u32 entry_cnt = 0;
193 struct voltage_device *pvolt_dev = NULL;
194 struct voltage_device_pwm *pvolt_dev_pwm = NULL;
195 struct voltage_device_pwm *ptmp_dev = NULL;
196 u32 duty_cycle;
197 u32 frequency_hz;
198 u32 voltage_uv;
199 u8 ext_dev_idx;
200 u8 steps;
201 u8 volt_domain = 0;
202 struct voltage_device_pwm_entry pwm_entry = { { 0 } };
203
204 ptmp_dev = kzalloc(sizeof(struct voltage_device_pwm), GFP_KERNEL);
205 if (ptmp_dev == NULL)
206 return -ENOMEM;
207
208 frequency_hz = (u32)BIOS_GET_FIELD(p_bios_entry->param0,
209 NV_VBIOS_VDT_1X_ENTRY_PARAM0_PSV_INPUT_FREQUENCY);
210
211 ext_dev_idx = (u8)BIOS_GET_FIELD(p_bios_entry->param0,
212 NV_VBIOS_VDT_1X_ENTRY_PARAM0_PSV_EXT_DEVICE_INDEX);
213
214 ptmp_dev->super.operation_type = volt_dev_operation_type_convert(
215 (u8)BIOS_GET_FIELD(p_bios_entry->param1,
216 NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_OPERATION_TYPE));
217
218 if (ptmp_dev->super.operation_type ==
219 CTRL_VOLT_DEVICE_OPERATION_TYPE_INVALID) {
220 gk20a_err(dev_from_gk20a(g),
221 " Invalid Voltage Device Operation Type.");
222
223 status = -EINVAL;
224 goto done;
225 }
226
227 ptmp_dev->super.voltage_min_uv =
228 (u32)BIOS_GET_FIELD(p_bios_entry->param1,
229 NV_VBIOS_VDT_1X_ENTRY_PARAM1_PSV_VOLTAGE_MINIMUM);
230
231 ptmp_dev->super.voltage_max_uv =
232 (u32)BIOS_GET_FIELD(p_bios_entry->param2,
233 NV_VBIOS_VDT_1X_ENTRY_PARAM2_PSV_VOLTAGE_MAXIMUM);
234
235 ptmp_dev->voltage_base_uv = BIOS_GET_FIELD(p_bios_entry->param3,
236 NV_VBIOS_VDT_1X_ENTRY_PARAM3_PSV_VOLTAGE_BASE);
237
238 steps = (u8)BIOS_GET_FIELD(p_bios_entry->param3,
239 NV_VBIOS_VDT_1X_ENTRY_PARAM3_PSV_VOLTAGE_STEPS);
240 if (steps == VOLT_DEV_PWM_VOLTAGE_STEPS_INVALID)
241 steps = VOLT_DEV_PWM_VOLTAGE_STEPS_DEFAULT;
242
243 ptmp_dev->voltage_offset_scale_uv =
244 BIOS_GET_FIELD(p_bios_entry->param4,
245 NV_VBIOS_VDT_1X_ENTRY_PARAM4_PSV_OFFSET_SCALE);
246
247 volt_domain = volt_rail_vbios_volt_domain_convert_to_internal(g,
248 (u8)p_bios_entry->volt_domain);
249 if (volt_domain == CTRL_VOLT_DOMAIN_INVALID) {
250 gk20a_err(dev_from_gk20a(g),
251 "invalid voltage domain = %d",
252 (u8)p_bios_entry->volt_domain);
253 status = -EINVAL;
254 goto done;
255 }
256
257 if (ptmp_dev->super.operation_type ==
258 CTRL_VOLT_DEVICE_OPERATION_TYPE_DEFAULT) {
259 if (volt_domain == CTRL_VOLT_DOMAIN_LOGIC)
260 ptmp_dev->source =
261 NV_PMU_PMGR_PWM_SOURCE_THERM_VID_PWM_0;
262 if (volt_domain == CTRL_VOLT_DOMAIN_SRAM)
263 ptmp_dev->source =
264 NV_PMU_PMGR_PWM_SOURCE_THERM_VID_PWM_1;
265 ptmp_dev->raw_period =
266 g->ops.clk.get_crystal_clk_hz(g) / frequency_hz;
267 } else if (ptmp_dev->super.operation_type ==
268 CTRL_VOLT_DEVICE_OPERATION_TYPE_LPWR_STEADY_STATE) {
269 ptmp_dev->source = NV_PMU_PMGR_PWM_SOURCE_RSVD_0;
270 ptmp_dev->raw_period = 0;
271 } else if (ptmp_dev->super.operation_type ==
272 CTRL_VOLT_DEVICE_OPERATION_TYPE_LPWR_SLEEP_STATE) {
273 ptmp_dev->source = NV_PMU_PMGR_PWM_SOURCE_RSVD_1;
274 ptmp_dev->raw_period = 0;
275 }
276
277 /* Initialize data for parent class. */
278 ptmp_dev->super.super.type = CTRL_VOLT_DEVICE_TYPE_PWM;
279 ptmp_dev->super.volt_domain = volt_domain;
280 ptmp_dev->super.i2c_dev_idx = ext_dev_idx;
281 ptmp_dev->super.switch_delay_us = (u16)p_bios_entry->settle_time_us;
282
283 pvolt_dev = volt_volt_device_construct(g, ptmp_dev);
284 if (pvolt_dev == NULL) {
285 gk20a_err(dev_from_gk20a(g),
286 " Failure to construct VOLTAGE_DEVICE object.");
287
288 status = -EINVAL;
289 goto done;
290 }
291
292 status = boardobjgrp_objinsert(
293 &p_Volt_Device_Meta_Data->volt_devices.super,
294 (struct boardobj *)pvolt_dev, entry_Idx);
295 if (status) {
296 gk20a_err(dev_from_gk20a(g),
297 "could not add VOLTAGE_DEVICE for entry %d into boardobjgrp ",
298 entry_Idx);
299 goto done;
300 }
301
302 pvolt_dev_pwm = (struct voltage_device_pwm *)pvolt_dev;
303
304 duty_cycle = 0;
305 do {
306 voltage_uv = (u32)(pvolt_dev_pwm->voltage_base_uv +
307 (s32)((((s64)((s32)duty_cycle)) *
308 pvolt_dev_pwm->voltage_offset_scale_uv)
309 / ((s64)((s32) pvolt_dev_pwm->raw_period))));
310
311 /* Skip creating entry for invalid voltage. */
312 if ((voltage_uv >= pvolt_dev_pwm->super.voltage_min_uv) &&
313 (voltage_uv <= pvolt_dev_pwm->super.voltage_max_uv)) {
314 if (pvolt_dev_pwm->voltage_offset_scale_uv < 0)
315 pwm_entry.duty_cycle =
316 pvolt_dev_pwm->raw_period - duty_cycle;
317 else
318 pwm_entry.duty_cycle = duty_cycle;
319
320 /* Check if there is room left in the voltage table. */
321 if (entry_cnt == VOLTAGE_TABLE_MAX_ENTRIES) {
322 gk20a_err(dev_from_gk20a(g), "Voltage table is full");
323 status = -EINVAL;
324 goto done;
325 }
326
327 pvolt_dev->pentry[entry_cnt] =
328 volt_dev_construct_dev_entry_pwm(g,
329 voltage_uv, &pwm_entry);
330 if (pvolt_dev->pentry[entry_cnt] == NULL) {
331 gk20a_err(dev_from_gk20a(g),
332 " Error creating voltage_device_pwm_entry!");
333 status = -EINVAL;
334 goto done;
335 }
336
337 entry_cnt++;
338 }
339
340 /* Obtain next value after the specified steps. */
341 duty_cycle = duty_cycle + (u32)steps;
342
343 /* Cap duty cycle to PWM period. */
344 if (duty_cycle > pvolt_dev_pwm->raw_period)
345 duty_cycle = pvolt_dev_pwm->raw_period;
346
347 } while (duty_cycle < pvolt_dev_pwm->raw_period);
348
349done:
350 if (pvolt_dev != NULL)
351 pvolt_dev->num_entries = entry_cnt;
352
353 kfree(ptmp_dev);
354 return status;
355}
356
357static u32 volt_get_volt_devices_table(struct gk20a *g,
358 struct voltage_device_metadata *pvolt_device_metadata)
359{
360 u32 status = 0;
361 u8 *volt_device_table_ptr = NULL;
362 struct vbios_voltage_device_table_1x_header header = { 0 };
363 struct vbios_voltage_device_table_1x_entry entry = { 0 };
364 u8 entry_idx;
365 u8 *entry_offset;
366
367 if (g->ops.bios.get_perf_table_ptrs) {
368 volt_device_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
369 g->bios.perf_token, VOLTAGE_DEVICE_TABLE);
370 if (volt_device_table_ptr == NULL) {
371 status = -EINVAL;
372 goto done;
373 }
374 } else {
375 status = -EINVAL;
376 goto done;
377 }
378
379 memcpy(&header, volt_device_table_ptr,
380 sizeof(struct vbios_voltage_device_table_1x_header));
381
382 /* Read in the entries. */
383 for (entry_idx = 0; entry_idx < header.num_table_entries; entry_idx++) {
384 entry_offset = (volt_device_table_ptr + header.header_size +
385 (entry_idx * header.table_entry_size));
386
387 memcpy(&entry, entry_offset,
388 sizeof(struct vbios_voltage_device_table_1x_entry));
389
390 if (entry.type == NV_VBIOS_VOLTAGE_DEVICE_1X_ENTRY_TYPE_PSV)
391 status = volt_get_voltage_device_table_1x_psv(g,
392 &entry, pvolt_device_metadata,
393 entry_idx);
394 }
395
396done:
397 return status;
398}
399
400static u32 _volt_device_devgrp_pmudata_instget(struct gk20a *g,
401 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
402 struct nv_pmu_boardobj **ppboardobjpmudata, u8 idx)
403{
404 struct nv_pmu_volt_volt_device_boardobj_grp_set *pgrp_set =
405 (struct nv_pmu_volt_volt_device_boardobj_grp_set *)
406 pmuboardobjgrp;
407
408 gk20a_dbg_info("");
409
410 /*check whether pmuboardobjgrp has a valid boardobj in index*/
411 if (((u32)BIT(idx) &
412 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
413 return -EINVAL;
414
415 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
416 &pgrp_set->objects[idx].data.board_obj;
417 gk20a_dbg_info("Done");
418 return 0;
419}
420
421static u32 _volt_device_devgrp_pmustatus_instget(struct gk20a *g,
422 void *pboardobjgrppmu,
423 struct nv_pmu_boardobj_query **ppboardobjpmustatus, u8 idx)
424{
425 struct nv_pmu_volt_volt_device_boardobj_grp_get_status *pgrp_get_status
426 = (struct nv_pmu_volt_volt_device_boardobj_grp_get_status *)
427 pboardobjgrppmu;
428
429 /*check whether pmuboardobjgrp has a valid boardobj in index*/
430 if (((u32)BIT(idx) &
431 pgrp_get_status->hdr.data.super.obj_mask.super.data[0]) == 0)
432 return -EINVAL;
433
434 *ppboardobjpmustatus = (struct nv_pmu_boardobj_query *)
435 &pgrp_get_status->objects[idx].data.board_obj;
436 return 0;
437}
438
439static int volt_device_volt_cmp(const void *a, const void *b)
440{
441 const struct voltage_device_entry *a_entry = *(const struct voltage_device_entry **)a;
442 const struct voltage_device_entry *b_entry = *(const struct voltage_device_entry **)b;
443
444 return (int)a_entry->voltage_uv - (int)b_entry->voltage_uv;
445}
446
447u32 volt_device_state_init(struct gk20a *g, struct voltage_device *pvolt_dev)
448{
449 u32 status = 0;
450 struct voltage_rail *pRail = NULL;
451 u8 rail_idx = 0;
452
453 sort(pvolt_dev->pentry, pvolt_dev->num_entries,
454 sizeof(*pvolt_dev->pentry), volt_device_volt_cmp,
455 NULL);
456
457 /* Initialize VOLT_DEVICE step size. */
458 if (pvolt_dev->num_entries <= VOLTAGE_TABLE_MAX_ENTRIES_ONE)
459 pvolt_dev->volt_step_uv = NV_PMU_VOLT_VALUE_0V_IN_UV;
460 else
461 pvolt_dev->volt_step_uv = (pvolt_dev->pentry[1]->voltage_uv -
462 pvolt_dev->pentry[0]->voltage_uv);
463
464 /* Build VOLT_RAIL SW state from VOLT_DEVICE SW state. */
465 /* If VOLT_RAIL isn't supported, exit. */
466 if (VOLT_RAIL_VOLT_3X_SUPPORTED(&g->perf_pmu.volt)) {
467 rail_idx = volt_rail_volt_domain_convert_to_idx(g,
468 pvolt_dev->volt_domain);
469 if (rail_idx == CTRL_BOARDOBJ_IDX_INVALID) {
470 gk20a_err(dev_from_gk20a(g),
471 " could not convert voltage domain to rail index.");
472 status = -EINVAL;
473 goto done;
474 }
475
476 pRail = VOLT_GET_VOLT_RAIL(&g->perf_pmu.volt, rail_idx);
477 if (pRail == NULL) {
478 gk20a_err(dev_from_gk20a(g),
479 "could not obtain ptr to rail object from rail index");
480 status = -EINVAL;
481 goto done;
482 }
483
484 status = volt_rail_volt_dev_register(g, pRail,
485 BOARDOBJ_GET_IDX(pvolt_dev), pvolt_dev->operation_type);
486 if (status) {
487 gk20a_err(dev_from_gk20a(g),
488 "Failed to register the device with rail obj");
489 goto done;
490 }
491 }
492
493done:
494 if (status)
495 gk20a_err(dev_from_gk20a(g),
496 "Error in building rail sw state device sw");
497
498 return status;
499}
500
501u32 volt_dev_pmu_setup(struct gk20a *g)
502{
503 u32 status;
504 struct boardobjgrp *pboardobjgrp = NULL;
505
506 gk20a_dbg_info("");
507
508 pboardobjgrp = &g->perf_pmu.volt.volt_dev_metadata.volt_devices.super;
509
510 if (!pboardobjgrp->bconstructed)
511 return -EINVAL;
512
513 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
514
515 gk20a_dbg_info("Done");
516 return status;
517}
518
519u32 volt_dev_sw_setup(struct gk20a *g)
520{
521 u32 status = 0;
522 struct boardobjgrp *pboardobjgrp = NULL;
523 struct voltage_device *pvolt_device;
524 u8 i;
525
526 gk20a_dbg_info("");
527
528 status = boardobjgrpconstruct_e32(&g->perf_pmu.volt.volt_dev_metadata.
529 volt_devices);
530 if (status) {
531 gk20a_err(dev_from_gk20a(g),
532 "error creating boardobjgrp for volt rail, status - 0x%x",
533 status);
534 goto done;
535 }
536
537 pboardobjgrp = &g->perf_pmu.volt.volt_dev_metadata.volt_devices.super;
538
539 pboardobjgrp->pmudatainstget = _volt_device_devgrp_pmudata_instget;
540 pboardobjgrp->pmustatusinstget = _volt_device_devgrp_pmustatus_instget;
541
542 /* Obtain Voltage Rail Table from VBIOS */
543 status = volt_get_volt_devices_table(g, &g->perf_pmu.volt.
544 volt_dev_metadata);
545 if (status)
546 goto done;
547
548 /* Populate data for the VOLT_RAIL PMU interface */
549 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, VOLT, VOLT_DEVICE);
550
551 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
552 volt, VOLT, volt_device, VOLT_DEVICE);
553 if (status) {
554 gk20a_err(dev_from_gk20a(g),
555 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
556 status);
557 goto done;
558 }
559
560 status = BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g,
561 &g->perf_pmu.volt.volt_dev_metadata.volt_devices.super,
562 volt, VOLT, volt_device, VOLT_DEVICE);
563 if (status) {
564 gk20a_err(dev_from_gk20a(g),
565 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
566 status);
567 goto done;
568 }
569
570 /* update calibration to fuse */
571 BOARDOBJGRP_FOR_EACH(&(g->perf_pmu.volt.volt_dev_metadata.volt_devices.
572 super),
573 struct voltage_device *, pvolt_device, i) {
574 status = volt_device_state_init(g, pvolt_device);
575 if (status) {
576 gk20a_err(dev_from_gk20a(g),
577 "failure while executing devices's state init interface");
578 gk20a_err(dev_from_gk20a(g),
579 " railIdx = %d, status = 0x%x", i, status);
580 goto done;
581 }
582 }
583
584done:
585 gk20a_dbg_info(" done status %x", status);
586 return status;
587}
588
diff --git a/drivers/gpu/nvgpu/volt/volt_dev.h b/drivers/gpu/nvgpu/volt/volt_dev.h
new file mode 100644
index 00000000..5113567d
--- /dev/null
+++ b/drivers/gpu/nvgpu/volt/volt_dev.h
@@ -0,0 +1,69 @@
1/*
2* Copyright (c) 2016, 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
14
15#ifndef _VOLTDEV_H_
16#define _VOLTDEV_H_
17
18#include "boardobj/boardobj.h"
19#include "boardobj/boardobjgrp.h"
20#include "ctrl/ctrlvolt.h"
21
22#define VOLTAGE_TABLE_MAX_ENTRIES_ONE 1
23#define VOLTAGE_TABLE_MAX_ENTRIES 256
24
25struct voltage_device {
26 struct boardobj super;
27 u8 volt_domain;
28 u8 i2c_dev_idx;
29 u32 switch_delay_us;
30 u32 num_entries;
31 struct voltage_device_entry *pentry[VOLTAGE_TABLE_MAX_ENTRIES];
32 struct voltage_device_entry *pcurr_entry;
33 u8 rsvd_0;
34 u8 rsvd_1;
35 u8 operation_type;
36 u32 voltage_min_uv;
37 u32 voltage_max_uv;
38 u32 volt_step_uv;
39};
40
41struct voltage_device_entry {
42 u32 voltage_uv;
43};
44
45struct voltage_device_metadata {
46 struct boardobjgrp_e32 volt_devices;
47};
48
49/*!
50 * Extends VOLTAGE_DEVICE providing attributes specific to PWM controllers.
51 */
52struct voltage_device_pwm {
53 struct voltage_device super;
54 s32 voltage_base_uv;
55 s32 voltage_offset_scale_uv;
56 enum nv_pmu_pmgr_pwm_source source;
57 u32 raw_period;
58};
59
60struct voltage_device_pwm_entry {
61 struct voltage_device_entry super;
62 u32 duty_cycle;
63};
64/* PWM end */
65
66u32 volt_dev_sw_setup(struct gk20a *g);
67u32 volt_dev_pmu_setup(struct gk20a *g);
68
69#endif /* _VOLTDEV_H_ */
diff --git a/drivers/gpu/nvgpu/volt/volt_pmu.c b/drivers/gpu/nvgpu/volt/volt_pmu.c
new file mode 100644
index 00000000..4e7f73c9
--- /dev/null
+++ b/drivers/gpu/nvgpu/volt/volt_pmu.c
@@ -0,0 +1,276 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "include/bios.h"
16#include "boardobj/boardobjgrp.h"
17#include "boardobj/boardobjgrp_e32.h"
18#include "pmuif/gpmuifboardobj.h"
19#include "gm206/bios_gm206.h"
20#include "ctrl/ctrlvolt.h"
21#include "ctrl/ctrlperf.h"
22#include "gk20a/pmu_gk20a.h"
23
24#include "pmuif/gpmuifperfvfe.h"
25#include "pmuif/gpmuifvolt.h"
26#include "include/bios.h"
27#include "volt.h"
28
29#define RAIL_COUNT 2
30
31struct volt_rpc_pmucmdhandler_params {
32 struct nv_pmu_volt_rpc *prpc_call;
33 u32 success;
34};
35
36static void volt_rpc_pmucmdhandler(struct gk20a *g, struct pmu_msg *msg,
37 void *param, u32 handle, u32 status)
38{
39 struct volt_rpc_pmucmdhandler_params *phandlerparams =
40 (struct volt_rpc_pmucmdhandler_params *)param;
41
42 gk20a_dbg_info("");
43
44 if (msg->msg.volt.msg_type != NV_PMU_VOLT_MSG_ID_RPC) {
45 gk20a_err(dev_from_gk20a(g), "unsupported msg for VOLT RPC %x",
46 msg->msg.volt.msg_type);
47 return;
48 }
49
50 if (phandlerparams->prpc_call->b_supported)
51 phandlerparams->success = 1;
52}
53
54
55static u32 volt_pmu_rpc_execute(struct gk20a *g,
56 struct nv_pmu_volt_rpc *prpc_call)
57{
58 struct pmu_cmd cmd = { { 0 } };
59 struct pmu_msg msg = { { 0 } };
60 struct pmu_payload payload = { { 0 } };
61 u32 status = 0;
62 u32 seqdesc;
63 struct volt_rpc_pmucmdhandler_params handler = {0};
64
65 cmd.hdr.unit_id = PMU_UNIT_VOLT;
66 cmd.hdr.size = (u32)sizeof(struct nv_pmu_volt_cmd) +
67 (u32)sizeof(struct pmu_hdr);
68 cmd.cmd.volt.cmd_type = NV_PMU_VOLT_CMD_ID_RPC;
69 msg.hdr.size = sizeof(struct pmu_msg);
70
71 payload.in.buf = (u8 *)prpc_call;
72 payload.in.size = (u32)sizeof(struct nv_pmu_volt_rpc);
73 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
74 payload.in.offset = NV_PMU_VOLT_CMD_RPC_ALLOC_OFFSET;
75
76 payload.out.buf = (u8 *)prpc_call;
77 payload.out.size = (u32)sizeof(struct nv_pmu_volt_rpc);
78 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
79 payload.out.offset = NV_PMU_VOLT_MSG_RPC_ALLOC_OFFSET;
80
81 handler.prpc_call = prpc_call;
82 handler.success = 0;
83
84 status = gk20a_pmu_cmd_post(g, &cmd, NULL, &payload,
85 PMU_COMMAND_QUEUE_LPQ,
86 volt_rpc_pmucmdhandler, (void *)&handler,
87 &seqdesc, ~0);
88 if (status) {
89 gk20a_err(dev_from_gk20a(g), "unable to post volt RPC cmd %x",
90 cmd.cmd.volt.cmd_type);
91 goto volt_pmu_rpc_execute;
92 }
93
94 pmu_wait_message_cond(&g->pmu,
95 gk20a_get_gr_idle_timeout(g),
96 &handler.success, 1);
97
98 if (handler.success == 0) {
99 status = -EINVAL;
100 gk20a_err(dev_from_gk20a(g), "rpc call to volt failed");
101 }
102
103volt_pmu_rpc_execute:
104 return status;
105}
106
107u32 volt_pmu_send_load_cmd_to_pmu(struct gk20a *g)
108{
109 struct nv_pmu_volt_rpc rpc_call = { 0 };
110 u32 status = 0;
111
112 rpc_call.function = NV_PMU_VOLT_RPC_ID_LOAD;
113
114 status = volt_pmu_rpc_execute(g, &rpc_call);
115 if (status)
116 gk20a_err(dev_from_gk20a(g),
117 "Error while executing LOAD RPC: status = 0x%08x.",
118 status);
119
120 return status;
121}
122
123static u32 volt_rail_get_voltage(struct gk20a *g,
124 u8 volt_domain, u32 *pvoltage_uv)
125{
126 struct nv_pmu_volt_rpc rpc_call = { 0 };
127 u32 status = 0;
128 u8 rail_idx;
129
130 rail_idx = volt_rail_volt_domain_convert_to_idx(g, volt_domain);
131 if ((rail_idx == CTRL_VOLT_RAIL_INDEX_INVALID) ||
132 (!VOLT_RAIL_INDEX_IS_VALID(&g->perf_pmu.volt, rail_idx))) {
133 gk20a_err(dev_from_gk20a(g),
134 "failed: volt_domain = %d, voltage rail table = %d.",
135 volt_domain, rail_idx);
136 return -EINVAL;
137 }
138
139 /* Set RPC parameters. */
140 rpc_call.function = NV_PMU_VOLT_RPC_ID_VOLT_RAIL_GET_VOLTAGE;
141 rpc_call.params.volt_rail_get_voltage.rail_idx = rail_idx;
142
143 /* Execute the voltage get request via PMU RPC. */
144 status = volt_pmu_rpc_execute(g, &rpc_call);
145 if (status) {
146 gk20a_err(dev_from_gk20a(g),
147 "Error while executing volt_rail_get_voltage rpc");
148 return status;
149 }
150
151 /* Copy out the current voltage. */
152 *pvoltage_uv = rpc_call.params.volt_rail_get_voltage.voltage_uv;
153
154 return status;
155}
156
157
158static u32 volt_policy_set_voltage(struct gk20a *g, u8 client_id,
159 struct ctrl_perf_volt_rail_list *prail_list)
160{
161 struct nv_pmu_volt_rpc rpc_call = { 0 };
162 struct obj_volt *pvolt = &g->perf_pmu.volt;
163 u32 status = 0;
164 u8 policy_idx = CTRL_VOLT_POLICY_INDEX_INVALID;
165 u8 i = 0;
166
167 /* Sanity check input rail list. */
168 for (i = 0; i < prail_list->num_rails; i++) {
169 if ((prail_list->rails[i].volt_domain ==
170 CTRL_VOLT_DOMAIN_INVALID) ||
171 (prail_list->rails[i].voltage_uv ==
172 NV_PMU_VOLT_VALUE_0V_IN_UV)) {
173 gk20a_err(dev_from_gk20a(g), "Invalid voltage domain or target ");
174 gk20a_err(dev_from_gk20a(g), " client_id = %d, listEntry = %d ",
175 client_id, i);
176 gk20a_err(dev_from_gk20a(g),
177 "volt_domain = %d, voltage_uv = %d uV.",
178 prail_list->rails[i].volt_domain,
179 prail_list->rails[i].voltage_uv);
180 status = -EINVAL;
181 goto exit;
182 }
183 }
184
185 /* Convert the client ID to index. */
186 if (client_id == CTRL_VOLT_POLICY_CLIENT_PERF_CORE_VF_SEQ)
187 policy_idx =
188 pvolt->volt_policy_metadata.perf_core_vf_seq_policy_idx;
189 else {
190 status = -EINVAL;
191 goto exit;
192 }
193
194 /* Set RPC parameters. */
195 rpc_call.function = NV_PMU_VOLT_RPC_ID_VOLT_POLICY_SET_VOLTAGE;
196 rpc_call.params.volt_policy_voltage_data.policy_idx = policy_idx;
197 memcpy(&rpc_call.params.volt_policy_voltage_data.rail_list, prail_list,
198 (sizeof(struct ctrl_perf_volt_rail_list)));
199
200 /* Execute the voltage change request via PMU RPC. */
201 status = volt_pmu_rpc_execute(g, &rpc_call);
202 if (status)
203 gk20a_err(dev_from_gk20a(g),
204 "Error while executing VOLT_POLICY_SET_VOLTAGE RPC");
205
206exit:
207 return status;
208}
209
210u32 volt_set_voltage(struct gk20a *g, u32 logic_voltage_uv, u32 sram_voltage_uv)
211{
212 u32 status = 0;
213 struct ctrl_perf_volt_rail_list rail_list = { 0 };
214
215 rail_list.num_rails = RAIL_COUNT;
216 rail_list.rails[0].volt_domain = CTRL_VOLT_DOMAIN_LOGIC;
217 rail_list.rails[0].voltage_uv = logic_voltage_uv;
218 rail_list.rails[0].voltage_min_noise_unaware_uv = logic_voltage_uv;
219 rail_list.rails[1].volt_domain = CTRL_VOLT_DOMAIN_SRAM;
220 rail_list.rails[1].voltage_uv = sram_voltage_uv;
221 rail_list.rails[1].voltage_min_noise_unaware_uv = sram_voltage_uv;
222
223 status = volt_policy_set_voltage(g,
224 CTRL_VOLT_POLICY_CLIENT_PERF_CORE_VF_SEQ, &rail_list);
225
226 return status;
227
228}
229
230u32 volt_get_voltage(struct gk20a *g, u32 volt_domain, u32 *voltage_uv)
231{
232 return volt_rail_get_voltage(g, volt_domain, voltage_uv);
233}
234
235static int volt_policy_set_noiseaware_vmin(struct gk20a *g,
236 struct ctrl_volt_volt_rail_list *prail_list)
237{
238 struct nv_pmu_volt_rpc rpc_call = { 0 };
239 u32 status = 0;
240
241 /* Set RPC parameters. */
242 rpc_call.function = NV_PMU_VOLT_RPC_ID_VOLT_RAIL_SET_NOISE_UNAWARE_VMIN;
243 rpc_call.params.volt_rail_set_noise_unaware_vmin.num_rails =
244 prail_list->num_rails;
245 memcpy(&rpc_call.params.volt_rail_set_noise_unaware_vmin.rail_list,
246 prail_list, (sizeof(struct ctrl_volt_volt_rail_list)));
247
248 /* Execute the voltage change request via PMU RPC. */
249 status = volt_pmu_rpc_execute(g, &rpc_call);
250 if (status) {
251 gk20a_err(dev_from_gk20a(g),
252 "Error while executing VOLT_POLICY_SET_VOLTAGE RPC");
253 return -EINVAL;
254 }
255
256 return 0;
257}
258
259int volt_set_noiseaware_vmin(struct gk20a *g, u32 logic_voltage_uv,
260 u32 sram_voltage_uv)
261{
262 int status = 0;
263 struct ctrl_volt_volt_rail_list rail_list = { 0 };
264
265 rail_list.num_rails = RAIL_COUNT;
266 rail_list.rails[0].rail_idx = 0;
267 rail_list.rails[0].voltage_uv = logic_voltage_uv;
268 rail_list.rails[1].rail_idx = 1;
269 rail_list.rails[1].voltage_uv = sram_voltage_uv;
270
271 status = volt_policy_set_noiseaware_vmin(g, &rail_list);
272
273 return status;
274
275}
276
diff --git a/drivers/gpu/nvgpu/volt/volt_pmu.h b/drivers/gpu/nvgpu/volt/volt_pmu.h
new file mode 100644
index 00000000..7e639375
--- /dev/null
+++ b/drivers/gpu/nvgpu/volt/volt_pmu.h
@@ -0,0 +1,23 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _VOLT_PMU_H_
15#define _VOLT_PMU_H_
16
17u32 volt_pmu_send_load_cmd_to_pmu(struct gk20a *g);
18u32 volt_set_voltage(struct gk20a *g, u32 logic_voltage_uv,
19 u32 sram_voltage_uv);
20u32 volt_get_voltage(struct gk20a *g, u32 volt_domain, u32 *voltage_uv);
21int volt_set_noiseaware_vmin(struct gk20a *g, u32 logic_voltage_uv,
22 u32 sram_voltage_uv);
23#endif
diff --git a/drivers/gpu/nvgpu/volt/volt_policy.c b/drivers/gpu/nvgpu/volt/volt_policy.c
new file mode 100644
index 00000000..ee3e74b8
--- /dev/null
+++ b/drivers/gpu/nvgpu/volt/volt_policy.c
@@ -0,0 +1,360 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "include/bios.h"
16#include "boardobj/boardobjgrp.h"
17#include "boardobj/boardobjgrp_e32.h"
18#include "pmuif/gpmuifboardobj.h"
19#include "gm206/bios_gm206.h"
20#include "ctrl/ctrlvolt.h"
21#include "gk20a/pmu_gk20a.h"
22
23#include "pmuif/gpmuifperfvfe.h"
24#include "include/bios.h"
25#include "volt.h"
26
27static u32 volt_policy_pmu_data_init_super(struct gk20a *g,
28 struct boardobj *pboardobj, struct nv_pmu_boardobj *ppmudata)
29{
30 return boardobj_pmudatainit_super(g, pboardobj, ppmudata);
31}
32
33static u32 construct_volt_policy(struct gk20a *g,
34 struct boardobj **ppboardobj, u16 size, void *pArgs)
35{
36 struct voltage_policy *pvolt_policy = NULL;
37 u32 status = 0;
38
39 status = boardobj_construct_super(g, ppboardobj, size, pArgs);
40 if (status)
41 return status;
42
43 pvolt_policy = (struct voltage_policy *)*ppboardobj;
44
45 pvolt_policy->super.pmudatainit = volt_policy_pmu_data_init_super;
46
47 return status;
48}
49
50static u32 construct_volt_policy_split_rail(struct gk20a *g,
51 struct boardobj **ppboardobj, u16 size, void *pArgs)
52{
53 struct voltage_policy_split_rail *ptmp_policy =
54 (struct voltage_policy_split_rail *)pArgs;
55 struct voltage_policy_split_rail *pvolt_policy = NULL;
56 u32 status = 0;
57
58 status = construct_volt_policy(g, ppboardobj, size, pArgs);
59 if (status)
60 return status;
61
62 pvolt_policy = (struct voltage_policy_split_rail *)*ppboardobj;
63
64 pvolt_policy->rail_idx_master = ptmp_policy->rail_idx_master;
65 pvolt_policy->rail_idx_slave = ptmp_policy->rail_idx_slave;
66 pvolt_policy->delta_min_vfe_equ_idx =
67 ptmp_policy->delta_min_vfe_equ_idx;
68 pvolt_policy->delta_max_vfe_equ_idx =
69 ptmp_policy->delta_max_vfe_equ_idx;
70
71 return status;
72}
73
74u32 volt_policy_pmu_data_init_split_rail(struct gk20a *g,
75 struct boardobj *pboardobj, struct nv_pmu_boardobj *ppmudata)
76{
77 u32 status = 0;
78 struct voltage_policy_split_rail *ppolicy;
79 struct nv_pmu_volt_volt_policy_splt_r_boardobj_set *pset;
80
81 status = volt_policy_pmu_data_init_super(g, pboardobj, ppmudata);
82 if (status)
83 goto done;
84
85 ppolicy = (struct voltage_policy_split_rail *)pboardobj;
86 pset = (struct nv_pmu_volt_volt_policy_splt_r_boardobj_set *)
87 ppmudata;
88
89 pset->rail_idx_master = ppolicy->rail_idx_master;
90 pset->rail_idx_slave = ppolicy->rail_idx_slave;
91 pset->delta_min_vfe_equ_idx = ppolicy->delta_min_vfe_equ_idx;
92 pset->delta_max_vfe_equ_idx = ppolicy->delta_max_vfe_equ_idx;
93 pset->offset_delta_min_uv = ppolicy->offset_delta_min_uv;
94 pset->offset_delta_max_uv = ppolicy->offset_delta_max_uv;
95
96done:
97 return status;
98}
99
100static u32 volt_construct_volt_policy_split_rail_single_step(struct gk20a *g,
101 struct boardobj **ppboardobj, u16 size, void *pargs)
102{
103 struct boardobj *pboardobj = NULL;
104 struct voltage_policy_split_rail_single_step *p_volt_policy = NULL;
105 u32 status = 0;
106
107 status = construct_volt_policy_split_rail(g, ppboardobj, size, pargs);
108 if (status)
109 return status;
110
111 pboardobj = (*ppboardobj);
112 p_volt_policy = (struct voltage_policy_split_rail_single_step *)
113 *ppboardobj;
114
115 pboardobj->pmudatainit = volt_policy_pmu_data_init_split_rail;
116
117 return status;
118}
119
120struct voltage_policy *volt_volt_policy_construct(struct gk20a *g, void *pargs)
121{
122 struct boardobj *pboard_obj = NULL;
123 u32 status = 0;
124
125 if (BOARDOBJ_GET_TYPE(pargs) ==
126 CTRL_VOLT_POLICY_TYPE_SR_SINGLE_STEP) {
127 status = volt_construct_volt_policy_split_rail_single_step(g,
128 &pboard_obj,
129 sizeof(struct voltage_policy_split_rail_single_step),
130 pargs);
131 if (status) {
132 gk20a_err(dev_from_gk20a(g),
133 "Could not allocate memory for voltage_policy");
134 pboard_obj = NULL;
135 }
136 }
137
138 return (struct voltage_policy *)pboard_obj;
139}
140
141static u8 volt_policy_type_convert(u8 vbios_type)
142{
143 switch (vbios_type) {
144 case NV_VBIOS_VOLTAGE_POLICY_1X_ENTRY_TYPE_SINGLE_RAIL:
145 return CTRL_VOLT_POLICY_TYPE_SINGLE_RAIL;
146
147 case NV_VBIOS_VOLTAGE_POLICY_1X_ENTRY_TYPE_SR_MULTI_STEP:
148 return CTRL_VOLT_POLICY_TYPE_SR_MULTI_STEP;
149
150 case NV_VBIOS_VOLTAGE_POLICY_1X_ENTRY_TYPE_SR_SINGLE_STEP:
151 return CTRL_VOLT_POLICY_TYPE_SR_SINGLE_STEP;
152 }
153
154 return CTRL_VOLT_POLICY_TYPE_INVALID;
155}
156
157static u32 volt_get_volt_policy_table(struct gk20a *g,
158 struct voltage_policy_metadata *pvolt_policy_metadata)
159{
160 u32 status = 0;
161 u8 *voltage_policy_table_ptr = NULL;
162 struct voltage_policy *ppolicy = NULL;
163 struct vbios_voltage_policy_table_1x_header header = { 0 };
164 struct vbios_voltage_policy_table_1x_entry entry = { 0 };
165 u8 i;
166 u8 policy_type = 0;
167 u8 *entry_offset;
168 union policy_type {
169 struct boardobj board_obj;
170 struct voltage_policy volt_policy;
171 struct voltage_policy_split_rail split_rail;
172 } policy_type_data;
173
174 if (g->ops.bios.get_perf_table_ptrs) {
175 voltage_policy_table_ptr =
176 (u8 *)g->ops.bios.get_perf_table_ptrs(g,
177 g->bios.perf_token, VOLTAGE_POLICY_TABLE);
178 if (voltage_policy_table_ptr == NULL) {
179 status = -EINVAL;
180 goto done;
181 }
182 } else {
183 status = -EINVAL;
184 goto done;
185 }
186
187 memcpy(&header, voltage_policy_table_ptr,
188 sizeof(struct vbios_voltage_policy_table_1x_header));
189
190 /* Set Voltage Policy Table Index for Perf Core VF Sequence client. */
191 pvolt_policy_metadata->perf_core_vf_seq_policy_idx =
192 (u8)header.perf_core_vf_seq_policy_idx;
193
194 /* Read in the entries. */
195 for (i = 0; i < header.num_table_entries; i++) {
196 entry_offset = (voltage_policy_table_ptr + header.header_size +
197 i * header.table_entry_size);
198
199 memcpy(&entry, entry_offset,
200 sizeof(struct vbios_voltage_policy_table_1x_entry));
201
202 memset(&policy_type_data, 0x0, sizeof(policy_type_data));
203
204 policy_type = volt_policy_type_convert((u8)entry.type);
205
206 if (policy_type == CTRL_VOLT_POLICY_TYPE_SR_SINGLE_STEP) {
207 policy_type_data.split_rail.rail_idx_master =
208 (u8)BIOS_GET_FIELD(entry.param0,
209 NV_VBIOS_VPT_ENTRY_PARAM0_SR_VD_MASTER);
210
211 policy_type_data.split_rail.rail_idx_slave =
212 (u8)BIOS_GET_FIELD(entry.param0,
213 NV_VBIOS_VPT_ENTRY_PARAM0_SR_VD_SLAVE);
214
215 policy_type_data.split_rail.delta_min_vfe_equ_idx =
216 (u8)BIOS_GET_FIELD(entry.param0,
217 NV_VBIOS_VPT_ENTRY_PARAM0_SR_DELTA_SM_MIN);
218
219 policy_type_data.split_rail.delta_max_vfe_equ_idx =
220 (u8)BIOS_GET_FIELD(entry.param0,
221 NV_VBIOS_VPT_ENTRY_PARAM0_SR_DELTA_SM_MAX);
222 }
223
224 policy_type_data.board_obj.type = policy_type;
225
226 ppolicy = volt_volt_policy_construct(g,
227 (void *)&policy_type_data);
228 if (ppolicy == NULL) {
229 gk20a_err(dev_from_gk20a(g),
230 "Failure to construct VOLT_POLICY object.");
231 status = -EINVAL;
232 goto done;
233 }
234
235 status = boardobjgrp_objinsert(
236 &pvolt_policy_metadata->volt_policies.super,
237 (struct boardobj *)ppolicy, i);
238 if (status) {
239 gk20a_err(dev_from_gk20a(g),
240 "could not add volt_policy for entry %d into boardobjgrp ",
241 i);
242 goto done;
243 }
244 }
245
246done:
247 return status;
248}
249static u32 _volt_policy_devgrp_pmudata_instget(struct gk20a *g,
250 struct nv_pmu_boardobjgrp *pmuboardobjgrp,
251 struct nv_pmu_boardobj **ppboardobjpmudata, u8 idx)
252{
253 struct nv_pmu_volt_volt_policy_boardobj_grp_set *pgrp_set =
254 (struct nv_pmu_volt_volt_policy_boardobj_grp_set *)
255 pmuboardobjgrp;
256
257 gk20a_dbg_info("");
258
259 /*check whether pmuboardobjgrp has a valid boardobj in index*/
260 if (((u32)BIT(idx) &
261 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
262 return -EINVAL;
263
264 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
265 &pgrp_set->objects[idx].data.board_obj;
266 gk20a_dbg_info(" Done");
267 return 0;
268}
269
270static u32 _volt_policy_devgrp_pmustatus_instget(struct gk20a *g,
271 void *pboardobjgrppmu,
272 struct nv_pmu_boardobj_query **ppboardobjpmustatus, u8 idx)
273{
274 struct nv_pmu_volt_volt_policy_boardobj_grp_get_status *p_get_status =
275 (struct nv_pmu_volt_volt_policy_boardobj_grp_get_status *)
276 pboardobjgrppmu;
277
278 /*check whether pmuboardobjgrp has a valid boardobj in index*/
279 if (((u32)BIT(idx) &
280 p_get_status->hdr.data.super.obj_mask.super.data[0]) == 0)
281 return -EINVAL;
282
283 *ppboardobjpmustatus = (struct nv_pmu_boardobj_query *)
284 &p_get_status->objects[idx].data.board_obj;
285 return 0;
286}
287
288u32 volt_policy_pmu_setup(struct gk20a *g)
289{
290 u32 status;
291 struct boardobjgrp *pboardobjgrp = NULL;
292
293 gk20a_dbg_info("");
294
295 pboardobjgrp =
296 &g->perf_pmu.volt.volt_policy_metadata.volt_policies.super;
297
298 if (!pboardobjgrp->bconstructed)
299 return -EINVAL;
300
301 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
302
303 gk20a_dbg_info("Done");
304 return status;
305}
306
307u32 volt_policy_sw_setup(struct gk20a *g)
308{
309 u32 status = 0;
310 struct boardobjgrp *pboardobjgrp = NULL;
311
312 gk20a_dbg_info("");
313
314 status = boardobjgrpconstruct_e32(
315 &g->perf_pmu.volt.volt_policy_metadata.volt_policies);
316 if (status) {
317 gk20a_err(dev_from_gk20a(g),
318 "error creating boardobjgrp for volt rail, status - 0x%x",
319 status);
320 goto done;
321 }
322
323 pboardobjgrp =
324 &g->perf_pmu.volt.volt_policy_metadata.volt_policies.super;
325
326 pboardobjgrp->pmudatainstget = _volt_policy_devgrp_pmudata_instget;
327 pboardobjgrp->pmustatusinstget = _volt_policy_devgrp_pmustatus_instget;
328
329 /* Obtain Voltage Rail Table from VBIOS */
330 status = volt_get_volt_policy_table(g, &g->perf_pmu.volt.
331 volt_policy_metadata);
332 if (status)
333 goto done;
334
335 /* Populate data for the VOLT_RAIL PMU interface */
336 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, VOLT, VOLT_POLICY);
337
338 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
339 volt, VOLT, volt_policy, VOLT_POLICY);
340 if (status) {
341 gk20a_err(dev_from_gk20a(g),
342 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
343 status);
344 goto done;
345 }
346
347 status = BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g,
348 &g->perf_pmu.volt.volt_policy_metadata.volt_policies.super,
349 volt, VOLT, volt_policy, VOLT_POLICY);
350 if (status) {
351 gk20a_err(dev_from_gk20a(g),
352 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
353 status);
354 goto done;
355 }
356
357done:
358 gk20a_dbg_info(" done status %x", status);
359 return status;
360}
diff --git a/drivers/gpu/nvgpu/volt/volt_policy.h b/drivers/gpu/nvgpu/volt/volt_policy.h
new file mode 100644
index 00000000..6adbfd43
--- /dev/null
+++ b/drivers/gpu/nvgpu/volt/volt_policy.h
@@ -0,0 +1,64 @@
1/*
2* Copyright (c) 2016, 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
14#ifndef _VOLT_POLICY_H_
15#define _VOLT_POLICY_H_
16
17#define VOLT_POLICY_INDEX_IS_VALID(pvolt, policy_idx) \
18 (boardobjgrp_idxisvalid( \
19 &((pvolt)->volt_policy_metadata.volt_policies.super), \
20 (policy_idx)))
21
22/*!
23 * extends boardobj providing attributes common to all voltage_policies.
24 */
25struct voltage_policy {
26 struct boardobj super;
27};
28
29struct voltage_policy_metadata {
30 u8 perf_core_vf_seq_policy_idx;
31 struct boardobjgrp_e32 volt_policies;
32};
33
34/*!
35 * extends voltage_policy providing attributes
36 * common to all voltage_policy_split_rail.
37 */
38struct voltage_policy_split_rail {
39 struct voltage_policy super;
40 u8 rail_idx_master;
41 u8 rail_idx_slave;
42 u8 delta_min_vfe_equ_idx;
43 u8 delta_max_vfe_equ_idx;
44 s32 offset_delta_min_uv;
45 s32 offset_delta_max_uv;
46};
47
48struct voltage_policy_split_rail_single_step {
49 struct voltage_policy_split_rail super;
50};
51
52struct voltage_policy_split_rail_multi_step {
53 struct voltage_policy_split_rail super;
54 u16 inter_switch_delay_us;
55};
56
57struct voltage_policy_single_rail {
58 struct voltage_policy super;
59 u8 rail_idx;
60};
61
62u32 volt_policy_sw_setup(struct gk20a *g);
63u32 volt_policy_pmu_setup(struct gk20a *g);
64#endif
diff --git a/drivers/gpu/nvgpu/volt/volt_rail.c b/drivers/gpu/nvgpu/volt/volt_rail.c
new file mode 100644
index 00000000..87b85160
--- /dev/null
+++ b/drivers/gpu/nvgpu/volt/volt_rail.c
@@ -0,0 +1,438 @@
1/*
2 * Copyright (c) 2016, 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
14#include "gk20a/gk20a.h"
15#include "include/bios.h"
16#include "boardobj/boardobjgrp.h"
17#include "boardobj/boardobjgrp_e32.h"
18#include "pmuif/gpmuifboardobj.h"
19#include "gm206/bios_gm206.h"
20#include "ctrl/ctrlvolt.h"
21#include "gk20a/pmu_gk20a.h"
22
23#include "pmuif/gpmuifperfvfe.h"
24#include "include/bios.h"
25#include "volt.h"
26
27u8 volt_rail_volt_domain_convert_to_idx(struct gk20a *g, u8 volt_domain)
28{
29 switch (g->perf_pmu.volt.volt_rail_metadata.volt_domain_hal) {
30 case CTRL_VOLT_DOMAIN_HAL_GP10X_SINGLE_RAIL:
31 if (volt_domain == CTRL_BOARDOBJ_IDX_INVALID)
32 return 0;
33 break;
34 case CTRL_VOLT_DOMAIN_HAL_GP10X_SPLIT_RAIL:
35 switch (volt_domain) {
36 case CTRL_VOLT_DOMAIN_LOGIC:
37 return 0;
38 case CTRL_VOLT_DOMAIN_SRAM:
39 return 1;
40 }
41 break;
42 }
43
44 return CTRL_BOARDOBJ_IDX_INVALID;
45}
46
47u32 volt_rail_volt_dev_register(struct gk20a *g, struct voltage_rail
48 *pvolt_rail, u8 volt_dev_idx, u8 operation_type)
49{
50 u32 status = 0;
51
52 if (operation_type == CTRL_VOLT_DEVICE_OPERATION_TYPE_DEFAULT) {
53 if (pvolt_rail->volt_dev_idx_default ==
54 CTRL_BOARDOBJ_IDX_INVALID) {
55 pvolt_rail->volt_dev_idx_default = volt_dev_idx;
56 } else {
57 status = -EINVAL;
58 goto exit;
59 }
60 } else {
61 goto exit;
62 }
63
64 status = boardobjgrpmask_bitset(&pvolt_rail->volt_dev_mask.super,
65 volt_dev_idx);
66
67exit:
68 if (status)
69 gk20a_err(dev_from_gk20a(g), "Failed to register VOLTAGE_DEVICE");
70
71 return status;
72}
73
74static u32 volt_rail_state_init(struct gk20a *g,
75 struct voltage_rail *pvolt_rail)
76{
77 u32 status = 0;
78 u32 i;
79
80 pvolt_rail->volt_dev_idx_default = CTRL_BOARDOBJ_IDX_INVALID;
81
82 for (i = 0; i < CTRL_VOLT_RAIL_VOLT_DELTA_MAX_ENTRIES; i++) {
83 pvolt_rail->volt_delta_uv[i] = NV_PMU_VOLT_VALUE_0V_IN_UV;
84 g->perf_pmu.volt.volt_rail_metadata.ext_rel_delta_uv[i] =
85 NV_PMU_VOLT_VALUE_0V_IN_UV;
86 }
87
88 pvolt_rail->volt_margin_limit_vfe_equ_mon_handle =
89 NV_PMU_PERF_RPC_VFE_EQU_MONITOR_COUNT_MAX;
90 pvolt_rail->rel_limit_vfe_equ_mon_handle =
91 NV_PMU_PERF_RPC_VFE_EQU_MONITOR_COUNT_MAX;
92 pvolt_rail->alt_rel_limit_vfe_equ_mon_handle =
93 NV_PMU_PERF_RPC_VFE_EQU_MONITOR_COUNT_MAX;
94 pvolt_rail->ov_limit_vfe_equ_mon_handle =
95 NV_PMU_PERF_RPC_VFE_EQU_MONITOR_COUNT_MAX;
96
97 status = boardobjgrpmask_e32_init(&pvolt_rail->volt_dev_mask, NULL);
98 if (status) {
99 gk20a_err(dev_from_gk20a(g),
100 "Failed to initialize BOARDOBJGRPMASK of VOLTAGE_DEVICEs");
101 }
102
103 return status;
104}
105
106static u32 volt_rail_init_pmudata_super(struct gk20a *g,
107 struct boardobj *board_obj_ptr, struct nv_pmu_boardobj *ppmudata)
108{
109 u32 status = 0;
110 struct voltage_rail *prail;
111 struct nv_pmu_volt_volt_rail_boardobj_set *rail_pmu_data;
112 u32 i;
113
114 gk20a_dbg_info("");
115
116 status = boardobj_pmudatainit_super(g, board_obj_ptr, ppmudata);
117 if (status)
118 return status;
119
120 prail = (struct voltage_rail *)board_obj_ptr;
121 rail_pmu_data = (struct nv_pmu_volt_volt_rail_boardobj_set *)
122 ppmudata;
123
124 rail_pmu_data->rel_limit_vfe_equ_idx = prail->rel_limit_vfe_equ_idx;
125 rail_pmu_data->alt_rel_limit_vfe_equ_idx =
126 prail->alt_rel_limit_vfe_equ_idx;
127 rail_pmu_data->ov_limit_vfe_equ_idx = prail->ov_limit_vfe_equ_idx;
128 rail_pmu_data->vmin_limit_vfe_equ_idx = prail->vmin_limit_vfe_equ_idx;
129 rail_pmu_data->volt_margin_limit_vfe_equ_idx =
130 prail->volt_margin_limit_vfe_equ_idx;
131 rail_pmu_data->pwr_equ_idx = prail->pwr_equ_idx;
132 rail_pmu_data->volt_dev_idx_default = prail->volt_dev_idx_default;
133
134 for (i = 0; i < CTRL_VOLT_RAIL_VOLT_DELTA_MAX_ENTRIES; i++) {
135 rail_pmu_data->volt_delta_uv[i] = prail->volt_delta_uv[i] +
136 g->perf_pmu.volt.volt_rail_metadata.ext_rel_delta_uv[i];
137 }
138
139 status = boardobjgrpmask_export(&prail->volt_dev_mask.super,
140 prail->volt_dev_mask.super.bitcount,
141 &rail_pmu_data->volt_dev_mask.super);
142 if (status)
143 gk20a_err(dev_from_gk20a(g),
144 "Failed to export BOARDOBJGRPMASK of VOLTAGE_DEVICEs");
145
146 gk20a_dbg_info("Done");
147
148 return status;
149}
150
151static struct voltage_rail *construct_volt_rail(struct gk20a *g, void *pargs)
152{
153 struct boardobj *board_obj_ptr = NULL;
154 struct voltage_rail *ptemp_rail = (struct voltage_rail *)pargs;
155 struct voltage_rail *board_obj_volt_rail_ptr = NULL;
156 u32 status;
157
158 gk20a_dbg_info("");
159 status = boardobj_construct_super(g, &board_obj_ptr,
160 sizeof(struct voltage_rail), pargs);
161 if (status)
162 return NULL;
163
164 board_obj_volt_rail_ptr = (struct voltage_rail *)board_obj_ptr;
165 /* override super class interface */
166 board_obj_ptr->pmudatainit = volt_rail_init_pmudata_super;
167
168 board_obj_volt_rail_ptr->boot_voltage_uv =
169 ptemp_rail->boot_voltage_uv;
170 board_obj_volt_rail_ptr->rel_limit_vfe_equ_idx =
171 ptemp_rail->rel_limit_vfe_equ_idx;
172 board_obj_volt_rail_ptr->alt_rel_limit_vfe_equ_idx =
173 ptemp_rail->alt_rel_limit_vfe_equ_idx;
174 board_obj_volt_rail_ptr->ov_limit_vfe_equ_idx =
175 ptemp_rail->ov_limit_vfe_equ_idx;
176 board_obj_volt_rail_ptr->pwr_equ_idx =
177 ptemp_rail->pwr_equ_idx;
178 board_obj_volt_rail_ptr->boot_volt_vfe_equ_idx =
179 ptemp_rail->boot_volt_vfe_equ_idx;
180 board_obj_volt_rail_ptr->vmin_limit_vfe_equ_idx =
181 ptemp_rail->vmin_limit_vfe_equ_idx;
182 board_obj_volt_rail_ptr->volt_margin_limit_vfe_equ_idx =
183 ptemp_rail->volt_margin_limit_vfe_equ_idx;
184
185 gk20a_dbg_info("Done");
186
187 return (struct voltage_rail *)board_obj_ptr;
188}
189
190u8 volt_rail_vbios_volt_domain_convert_to_internal(struct gk20a *g,
191 u8 vbios_volt_domain)
192{
193 switch (g->perf_pmu.volt.volt_rail_metadata.volt_domain_hal) {
194 case CTRL_VOLT_DOMAIN_HAL_GP10X_SINGLE_RAIL:
195 if (vbios_volt_domain == 0)
196 return CTRL_VOLT_DOMAIN_LOGIC;
197 break;
198 case CTRL_VOLT_DOMAIN_HAL_GP10X_SPLIT_RAIL:
199 switch (vbios_volt_domain) {
200 case 0:
201 return CTRL_VOLT_DOMAIN_LOGIC;
202 case 1:
203 return CTRL_VOLT_DOMAIN_SRAM;
204 }
205 break;
206 }
207
208 return CTRL_VOLT_DOMAIN_INVALID;
209}
210
211u32 volt_rail_pmu_setup(struct gk20a *g)
212{
213 u32 status;
214 struct boardobjgrp *pboardobjgrp = NULL;
215
216 gk20a_dbg_info("");
217
218 pboardobjgrp = &g->perf_pmu.volt.volt_rail_metadata.volt_rails.super;
219
220 if (!pboardobjgrp->bconstructed)
221 return -EINVAL;
222
223 status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);
224
225 gk20a_dbg_info("Done");
226 return status;
227}
228
229static u32 volt_get_volt_rail_table(struct gk20a *g,
230 struct voltage_rail_metadata *pvolt_rail_metadata)
231{
232 u32 status = 0;
233 u8 *volt_rail_table_ptr = NULL;
234 struct voltage_rail *prail = NULL;
235 struct vbios_voltage_rail_table_1x_header header = { 0 };
236 struct vbios_voltage_rail_table_1x_entry entry = { 0 };
237 u8 i;
238 u8 volt_domain;
239 u8 *entry_ptr;
240 union rail_type {
241 struct boardobj board_obj;
242 struct voltage_rail volt_rail;
243 } rail_type_data;
244
245 if (g->ops.bios.get_perf_table_ptrs) {
246 volt_rail_table_ptr = (u8 *)g->ops.bios.get_perf_table_ptrs(g,
247 g->bios.perf_token, VOLTAGE_RAIL_TABLE);
248 if (volt_rail_table_ptr == NULL) {
249 status = -EINVAL;
250 goto done;
251 }
252 } else {
253 status = -EINVAL;
254 goto done;
255 }
256
257 memcpy(&header, volt_rail_table_ptr,
258 sizeof(struct vbios_voltage_rail_table_1x_header));
259
260 pvolt_rail_metadata->volt_domain_hal = (u8)header.volt_domain_hal;
261
262 for (i = 0; i < header.num_table_entries; i++) {
263 entry_ptr = (volt_rail_table_ptr + header.header_size +
264 (i * header.table_entry_size));
265
266 memset(&rail_type_data, 0x0, sizeof(rail_type_data));
267
268 memcpy(&entry, entry_ptr,
269 sizeof(struct vbios_voltage_rail_table_1x_entry));
270
271 volt_domain = volt_rail_vbios_volt_domain_convert_to_internal(g,
272 i);
273 if (volt_domain == CTRL_VOLT_DOMAIN_INVALID)
274 continue;
275
276 rail_type_data.board_obj.type = volt_domain;
277 rail_type_data.volt_rail.boot_voltage_uv =
278 (u32)entry.boot_voltage_uv;
279 rail_type_data.volt_rail.rel_limit_vfe_equ_idx =
280 (u8)entry.rel_limit_vfe_equ_idx;
281 rail_type_data.volt_rail.alt_rel_limit_vfe_equ_idx =
282 (u8)entry.alt_rel_limit_vfe_equidx;
283 rail_type_data.volt_rail.ov_limit_vfe_equ_idx =
284 (u8)entry.ov_limit_vfe_equ_idx;
285
286 if (header.table_entry_size >=
287 NV_VBIOS_VOLTAGE_RAIL_1X_ENTRY_SIZE_0B)
288 rail_type_data.volt_rail.volt_margin_limit_vfe_equ_idx =
289 (u8)entry.volt_margin_limit_vfe_equ_idx;
290 else
291 rail_type_data.volt_rail.volt_margin_limit_vfe_equ_idx =
292 CTRL_BOARDOBJ_IDX_INVALID;
293
294 if (header.table_entry_size >=
295 NV_VBIOS_VOLTAGE_RAIL_1X_ENTRY_SIZE_0A)
296 rail_type_data.volt_rail.vmin_limit_vfe_equ_idx =
297 (u8)entry.vmin_limit_vfe_equ_idx;
298 else
299 rail_type_data.volt_rail.vmin_limit_vfe_equ_idx =
300 CTRL_BOARDOBJ_IDX_INVALID;
301
302 if (header.table_entry_size >=
303 NV_VBIOS_VOLTAGE_RAIL_1X_ENTRY_SIZE_09)
304 rail_type_data.volt_rail.boot_volt_vfe_equ_idx =
305 (u8)entry.boot_volt_vfe_equ_idx;
306 else
307 rail_type_data.volt_rail.boot_volt_vfe_equ_idx =
308 CTRL_BOARDOBJ_IDX_INVALID;
309
310 if (header.table_entry_size >=
311 NV_VBIOS_VOLTAGE_RAIL_1X_ENTRY_SIZE_08)
312 rail_type_data.volt_rail.pwr_equ_idx =
313 (u8)entry.pwr_equ_idx;
314 else
315 rail_type_data.volt_rail.pwr_equ_idx =
316 CTRL_PMGR_PWR_EQUATION_INDEX_INVALID;
317
318 prail = construct_volt_rail(g, &rail_type_data);
319
320 status = boardobjgrp_objinsert(
321 &pvolt_rail_metadata->volt_rails.super,
322 (struct boardobj *)prail, i);
323 }
324
325done:
326 return status;
327}
328
329static u32 _volt_rail_devgrp_pmudata_instget(struct gk20a *g,
330 struct nv_pmu_boardobjgrp *pmuboardobjgrp, struct nv_pmu_boardobj
331 **ppboardobjpmudata, u8 idx)
332{
333 struct nv_pmu_volt_volt_rail_boardobj_grp_set *pgrp_set =
334 (struct nv_pmu_volt_volt_rail_boardobj_grp_set *)
335 pmuboardobjgrp;
336
337 gk20a_dbg_info("");
338
339 /*check whether pmuboardobjgrp has a valid boardobj in index*/
340 if (((u32)BIT(idx) &
341 pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0)
342 return -EINVAL;
343
344 *ppboardobjpmudata = (struct nv_pmu_boardobj *)
345 &pgrp_set->objects[idx].data.board_obj;
346 gk20a_dbg_info(" Done");
347 return 0;
348}
349
350static u32 _volt_rail_devgrp_pmustatus_instget(struct gk20a *g,
351 void *pboardobjgrppmu, struct nv_pmu_boardobj_query
352 **ppboardobjpmustatus, u8 idx)
353{
354 struct nv_pmu_volt_volt_rail_boardobj_grp_get_status *pgrp_get_status =
355 (struct nv_pmu_volt_volt_rail_boardobj_grp_get_status *)
356 pboardobjgrppmu;
357
358 /*check whether pmuboardobjgrp has a valid boardobj in index*/
359 if (((u32)BIT(idx) &
360 pgrp_get_status->hdr.data.super.obj_mask.super.data[0]) == 0)
361 return -EINVAL;
362
363 *ppboardobjpmustatus = (struct nv_pmu_boardobj_query *)
364 &pgrp_get_status->objects[idx].data.board_obj;
365 return 0;
366}
367
368u32 volt_rail_sw_setup(struct gk20a *g)
369{
370 u32 status = 0;
371 struct boardobjgrp *pboardobjgrp = NULL;
372 struct voltage_rail *pvolt_rail;
373 u8 i;
374
375 gk20a_dbg_info("");
376
377 status = boardobjgrpconstruct_e32(&g->perf_pmu.volt.volt_rail_metadata.
378 volt_rails);
379 if (status) {
380 gk20a_err(dev_from_gk20a(g),
381 "error creating boardobjgrp for volt rail, status - 0x%x",
382 status);
383 goto done;
384 }
385
386 pboardobjgrp = &g->perf_pmu.volt.volt_rail_metadata.volt_rails.super;
387
388 pboardobjgrp->pmudatainstget = _volt_rail_devgrp_pmudata_instget;
389 pboardobjgrp->pmustatusinstget = _volt_rail_devgrp_pmustatus_instget;
390
391 g->perf_pmu.volt.volt_rail_metadata.pct_delta =
392 NV_PMU_VOLT_VALUE_0V_IN_UV;
393
394 /* Obtain Voltage Rail Table from VBIOS */
395 status = volt_get_volt_rail_table(g, &g->perf_pmu.volt.
396 volt_rail_metadata);
397 if (status)
398 goto done;
399
400 /* Populate data for the VOLT_RAIL PMU interface */
401 BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, VOLT, VOLT_RAIL);
402
403 status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
404 volt, VOLT, volt_rail, VOLT_RAIL);
405 if (status) {
406 gk20a_err(dev_from_gk20a(g),
407 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
408 status);
409 goto done;
410 }
411
412 status = BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g,
413 &g->perf_pmu.volt.volt_rail_metadata.volt_rails.super,
414 volt, VOLT, volt_rail, VOLT_RAIL);
415 if (status) {
416 gk20a_err(dev_from_gk20a(g),
417 "error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
418 status);
419 goto done;
420 }
421
422 /* update calibration to fuse */
423 BOARDOBJGRP_FOR_EACH(&(g->perf_pmu.volt.volt_rail_metadata.
424 volt_rails.super),
425 struct voltage_rail *, pvolt_rail, i) {
426 status = volt_rail_state_init(g, pvolt_rail);
427 if (status) {
428 gk20a_err(dev_from_gk20a(g),
429 "Failure while executing RAIL's state init railIdx = %d",
430 i);
431 goto done;
432 }
433 }
434
435done:
436 gk20a_dbg_info(" done status %x", status);
437 return status;
438}
diff --git a/drivers/gpu/nvgpu/volt/volt_rail.h b/drivers/gpu/nvgpu/volt/volt_rail.h
new file mode 100644
index 00000000..8b930010
--- /dev/null
+++ b/drivers/gpu/nvgpu/volt/volt_rail.h
@@ -0,0 +1,79 @@
1/*
2* Copyright (c) 2016, 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
14
15#ifndef _VOLT_RAIL_H_
16#define _VOLT_RAIL_H_
17
18#include "boardobj/boardobj.h"
19#include "boardobj/boardobjgrp.h"
20
21#define CTRL_VOLT_RAIL_VOLT_DELTA_MAX_ENTRIES 0x04
22#define CTRL_PMGR_PWR_EQUATION_INDEX_INVALID 0xFF
23
24#define VOLT_GET_VOLT_RAIL(pvolt, rail_idx) \
25 ((struct voltage_rail *)BOARDOBJGRP_OBJ_GET_BY_IDX( \
26 &((pvolt)->volt_rail_metadata.volt_rails.super), (rail_idx)))
27
28#define VOLT_RAIL_INDEX_IS_VALID(pvolt, rail_idx) \
29 (boardobjgrp_idxisvalid( \
30 &((pvolt)->volt_rail_metadata.volt_rails.super), (rail_idx)))
31
32#define VOLT_RAIL_VOLT_3X_SUPPORTED(pvolt) \
33 (!BOARDOBJGRP_IS_EMPTY(&((pvolt)->volt_rail_metadata.volt_rails.super)))
34
35/*!
36 * extends boardobj providing attributes common to all voltage_rails.
37 */
38struct voltage_rail {
39 struct boardobj super;
40 u32 boot_voltage_uv;
41 u8 rel_limit_vfe_equ_idx;
42 u8 alt_rel_limit_vfe_equ_idx;
43 u8 ov_limit_vfe_equ_idx;
44 u8 pwr_equ_idx;
45 u8 volt_dev_idx_default;
46 u8 boot_volt_vfe_equ_idx;
47 u8 vmin_limit_vfe_equ_idx;
48 u8 volt_margin_limit_vfe_equ_idx;
49 u32 volt_margin_limit_vfe_equ_mon_handle;
50 u32 rel_limit_vfe_equ_mon_handle;
51 u32 alt_rel_limit_vfe_equ_mon_handle;
52 u32 ov_limit_vfe_equ_mon_handle;
53 struct boardobjgrpmask_e32 volt_dev_mask;
54 s32 volt_delta_uv[CTRL_VOLT_RAIL_VOLT_DELTA_MAX_ENTRIES];
55};
56
57/*!
58 * metadata of voltage rail functionality.
59 */
60struct voltage_rail_metadata {
61 u8 volt_domain_hal;
62 u8 pct_delta;
63 u32 ext_rel_delta_uv[CTRL_VOLT_RAIL_VOLT_DELTA_MAX_ENTRIES];
64 u8 logic_rail_idx;
65 u8 sram_rail_idx;
66 struct boardobjgrp_e32 volt_rails;
67};
68
69u8 volt_rail_vbios_volt_domain_convert_to_internal
70 (struct gk20a *g, u8 vbios_volt_domain);
71
72u32 volt_rail_volt_dev_register(struct gk20a *g, struct voltage_rail
73 *pvolt_rail, u8 volt_dev_idx, u8 operation_type);
74
75u8 volt_rail_volt_domain_convert_to_idx(struct gk20a *g, u8 volt_domain);
76
77u32 volt_rail_sw_setup(struct gk20a *g);
78u32 volt_rail_pmu_setup(struct gk20a *g);
79#endif
diff --git a/include/linux/tegra_vgpu_t18x.h b/include/linux/tegra_vgpu_t18x.h
new file mode 100644
index 00000000..121f4103
--- /dev/null
+++ b/include/linux/tegra_vgpu_t18x.h
@@ -0,0 +1,42 @@
1/*
2 * Tegra GPU Virtualization Interfaces to Server
3 *
4 * Copyright (c) 2015, NVIDIA Corporation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __TEGRA_VGPU_T18X_H
20#define __TEGRA_VGPU_T18X_H
21
22enum {
23 TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_MAIN,
24 TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_SPILL,
25 TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_PAGEPOOL,
26 TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_BETACB,
27 TEGRA_VGPU_GR_BIND_CTXSW_BUFFER_LAST
28};
29
30enum {
31 TEGRA_VGPU_GR_CTXSW_PREEMPTION_MODE_WFI,
32 TEGRA_VGPU_GR_CTXSW_PREEMPTION_MODE_GFX_GFXP,
33 TEGRA_VGPU_GR_CTXSW_PREEMPTION_MODE_COMPUTE_CTA,
34 TEGRA_VGPU_GR_CTXSW_PREEMPTION_MODE_COMPUTE_CILP,
35 TEGRA_VGPU_GR_CTXSW_PREEMPTION_MODE_LAST
36};
37
38enum {
39 TEGRA_VGPU_ATTRIB_PREEMPT_CTX_SIZE = 64
40};
41
42#endif
diff --git a/include/uapi/linux/nvgpu-t18x.h b/include/uapi/linux/nvgpu-t18x.h
new file mode 100644
index 00000000..777f1553
--- /dev/null
+++ b/include/uapi/linux/nvgpu-t18x.h
@@ -0,0 +1,74 @@
1/*
2 * NVGPU Public Interface Header
3 *
4 * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 */
15
16/* This file is meant to extend nvgpu.h, not replace it
17 * as such, be sure that nvgpu.h is actually the file performing the
18 * inclusion, to the extent that's possible.
19 */
20#ifndef _UAPI__LINUX_NVGPU_IOCTL_H
21# error "This file is to be included within nvgpu.h only."
22#endif
23
24#ifndef _UAPI__LINUX_NVGPU_T18X_IOCTL_H_
25#define _UAPI__LINUX_NVGPU_T18X_IOCTL_H_
26
27#define NVGPU_GPU_ARCH_GP100 0x00000130
28#define NVGPU_GPU_IMPL_GP104 0x00000004
29#define NVGPU_GPU_IMPL_GP106 0x00000006
30#define NVGPU_GPU_IMPL_GP10B 0x0000000B
31
32/*
33 * this flag is used in struct nvgpu_as_map_buffer_ex_args
34 * to specify IO coherence
35 */
36#define NVGPU_AS_MAP_BUFFER_FLAGS_IO_COHERENT (1 << 4)
37
38/*
39 * this flag is used in struct nvgpu_alloc_gpfifo_args
40 * to enable re-playable faults for that channel
41 */
42#define NVGPU_ALLOC_GPFIFO_FLAGS_REPLAYABLE_FAULTS_ENABLE (1 << 2)
43
44/* Flags in nvgpu_alloc_obj_ctx_args.flags */
45#define NVGPU_ALLOC_OBJ_FLAGS_GFXP (1 << 1)
46#define NVGPU_ALLOC_OBJ_FLAGS_CILP (1 << 2)
47
48/* Flags in nvgpu_preemption_mode_args.graphics_preempt_flags */
49#define NVGPU_GRAPHICS_PREEMPTION_MODE_GFXP (1 << 1)
50/* Flags in nvgpu_preemption_mode_args.compute_preempt_flags */
51#define NVGPU_COMPUTE_PREEMPTION_MODE_CILP (1 << 2)
52
53/* SM LRF ECC is enabled */
54#define NVGPU_GPU_FLAGS_ECC_ENABLED_SM_LRF (1ULL << 60)
55/* SM SHM ECC is enabled */
56#define NVGPU_GPU_FLAGS_ECC_ENABLED_SM_SHM (1ULL << 61)
57/* TEX ECC is enabled */
58#define NVGPU_GPU_FLAGS_ECC_ENABLED_TEX (1ULL << 62)
59/* L2 ECC is enabled */
60#define NVGPU_GPU_FLAGS_ECC_ENABLED_LTC (1ULL << 63)
61/* All types of ECC are enabled */
62#define NVGPU_GPU_FLAGS_ALL_ECC_ENABLED \
63 (NVGPU_GPU_FLAGS_ECC_ENABLED_SM_LRF | \
64 NVGPU_GPU_FLAGS_ECC_ENABLED_SM_SHM | \
65 NVGPU_GPU_FLAGS_ECC_ENABLED_TEX | \
66 NVGPU_GPU_FLAGS_ECC_ENABLED_LTC)
67
68/* Channel event_id in nvgpu_channel_events_ctrl_ext_args */
69#define NVGPU_IOCTL_CHANNEL_EVENT_ID_CILP_PREEMPTION_STARTED 3
70#define NVGPU_IOCTL_CHANNEL_EVENT_ID_CILP_PREEMPTION_COMPLETE 4
71
72#endif /* _UAPI__LINUX_NVGPU_T18X_IOCTL_H_ */
73
74