xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/pci/g92.c (revision d0034a7a4ac7fae708146ac0059b9c47a1543f0d)
1725af748SKarol Herbst /*
2725af748SKarol Herbst  * Copyright 2015 Red Hat Inc.
3725af748SKarol Herbst  *
4725af748SKarol Herbst  * Permission is hereby granted, free of charge, to any person obtaining a
5725af748SKarol Herbst  * copy of this software and associated documentation files (the "Software"),
6725af748SKarol Herbst  * to deal in the Software without restriction, including without limitation
7725af748SKarol Herbst  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8725af748SKarol Herbst  * and/or sell copies of the Software, and to permit persons to whom the
9725af748SKarol Herbst  * Software is furnished to do so, subject to the following conditions:
10725af748SKarol Herbst  *
11725af748SKarol Herbst  * The above copyright notice and this permission notice shall be included in
12725af748SKarol Herbst  * all copies or substantial portions of the Software.
13725af748SKarol Herbst  *
14725af748SKarol Herbst  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15725af748SKarol Herbst  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16725af748SKarol Herbst  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17725af748SKarol Herbst  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18725af748SKarol Herbst  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19725af748SKarol Herbst  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20725af748SKarol Herbst  * OTHER DEALINGS IN THE SOFTWARE.
21725af748SKarol Herbst  *
22725af748SKarol Herbst  * Authors: Ben Skeggs <bskeggs@redhat.com>
23725af748SKarol Herbst  */
24725af748SKarol Herbst #include "priv.h"
25725af748SKarol Herbst 
26725af748SKarol Herbst int
g92_pcie_version_supported(struct nvkm_pci * pci)27725af748SKarol Herbst g92_pcie_version_supported(struct nvkm_pci *pci)
28725af748SKarol Herbst {
29725af748SKarol Herbst 	if ((nvkm_pci_rd32(pci, 0x460) & 0x200) == 0x200)
30725af748SKarol Herbst 		return 2;
31725af748SKarol Herbst 	return 1;
32725af748SKarol Herbst }
33725af748SKarol Herbst 
34725af748SKarol Herbst static const struct nvkm_pci_func
35725af748SKarol Herbst g92_pci_func = {
36725af748SKarol Herbst 	.init = g84_pci_init,
37725af748SKarol Herbst 	.rd32 = nv40_pci_rd32,
38725af748SKarol Herbst 	.wr08 = nv40_pci_wr08,
39725af748SKarol Herbst 	.wr32 = nv40_pci_wr32,
405112abc6SKarol Herbst 	.msi_rearm = nv46_pci_msi_rearm,
41725af748SKarol Herbst 
42725af748SKarol Herbst 	.pcie.init = g84_pcie_init,
43725af748SKarol Herbst 	.pcie.set_link = g84_pcie_set_link,
44725af748SKarol Herbst 
45725af748SKarol Herbst 	.pcie.max_speed = g84_pcie_max_speed,
46725af748SKarol Herbst 	.pcie.cur_speed = g84_pcie_cur_speed,
47725af748SKarol Herbst 
48725af748SKarol Herbst 	.pcie.set_version = g84_pcie_set_version,
49725af748SKarol Herbst 	.pcie.version = g84_pcie_version,
50725af748SKarol Herbst 	.pcie.version_supported = g92_pcie_version_supported,
51725af748SKarol Herbst };
52725af748SKarol Herbst 
53725af748SKarol Herbst int
g92_pci_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_pci ** ppci)54*9b70cd54SBen Skeggs g92_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
55*9b70cd54SBen Skeggs 	    struct nvkm_pci **ppci)
56725af748SKarol Herbst {
57*9b70cd54SBen Skeggs 	return nvkm_pci_new_(&g92_pci_func, device, type, inst, ppci);
58725af748SKarol Herbst }
59