xref: /linux/drivers/gpu/drm/nouveau/nvkm/subdev/pci/nv40.c (revision d0034a7a4ac7fae708146ac0059b9c47a1543f0d)
10a34fb31SBen Skeggs /*
20a34fb31SBen Skeggs  * Copyright 2015 Red Hat Inc.
30a34fb31SBen Skeggs  *
40a34fb31SBen Skeggs  * Permission is hereby granted, free of charge, to any person obtaining a
50a34fb31SBen Skeggs  * copy of this software and associated documentation files (the "Software"),
60a34fb31SBen Skeggs  * to deal in the Software without restriction, including without limitation
70a34fb31SBen Skeggs  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
80a34fb31SBen Skeggs  * and/or sell copies of the Software, and to permit persons to whom the
90a34fb31SBen Skeggs  * Software is furnished to do so, subject to the following conditions:
100a34fb31SBen Skeggs  *
110a34fb31SBen Skeggs  * The above copyright notice and this permission notice shall be included in
120a34fb31SBen Skeggs  * all copies or substantial portions of the Software.
130a34fb31SBen Skeggs  *
140a34fb31SBen Skeggs  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
150a34fb31SBen Skeggs  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
160a34fb31SBen Skeggs  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
170a34fb31SBen Skeggs  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
180a34fb31SBen Skeggs  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
190a34fb31SBen Skeggs  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
200a34fb31SBen Skeggs  * OTHER DEALINGS IN THE SOFTWARE.
210a34fb31SBen Skeggs  *
220a34fb31SBen Skeggs  * Authors: Ben Skeggs <bskeggs@redhat.com>
230a34fb31SBen Skeggs  */
240a34fb31SBen Skeggs #include "priv.h"
250a34fb31SBen Skeggs 
260a34fb31SBen Skeggs u32
nv40_pci_rd32(struct nvkm_pci * pci,u16 addr)270a34fb31SBen Skeggs nv40_pci_rd32(struct nvkm_pci *pci, u16 addr)
280a34fb31SBen Skeggs {
290a34fb31SBen Skeggs 	struct nvkm_device *device = pci->subdev.device;
300a34fb31SBen Skeggs 	return nvkm_rd32(device, 0x088000 + addr);
310a34fb31SBen Skeggs }
320a34fb31SBen Skeggs 
330a34fb31SBen Skeggs void
nv40_pci_wr08(struct nvkm_pci * pci,u16 addr,u8 data)340a34fb31SBen Skeggs nv40_pci_wr08(struct nvkm_pci *pci, u16 addr, u8 data)
350a34fb31SBen Skeggs {
360a34fb31SBen Skeggs 	struct nvkm_device *device = pci->subdev.device;
370a34fb31SBen Skeggs 	nvkm_wr08(device, 0x088000 + addr, data);
380a34fb31SBen Skeggs }
390a34fb31SBen Skeggs 
400a34fb31SBen Skeggs void
nv40_pci_wr32(struct nvkm_pci * pci,u16 addr,u32 data)410a34fb31SBen Skeggs nv40_pci_wr32(struct nvkm_pci *pci, u16 addr, u32 data)
420a34fb31SBen Skeggs {
430a34fb31SBen Skeggs 	struct nvkm_device *device = pci->subdev.device;
440a34fb31SBen Skeggs 	nvkm_wr32(device, 0x088000 + addr, data);
450a34fb31SBen Skeggs }
460a34fb31SBen Skeggs 
47b31505c4SBen Skeggs void
nv40_pci_msi_rearm(struct nvkm_pci * pci)480a34fb31SBen Skeggs nv40_pci_msi_rearm(struct nvkm_pci *pci)
490a34fb31SBen Skeggs {
500a34fb31SBen Skeggs 	nvkm_pci_wr08(pci, 0x0068, 0xff);
510a34fb31SBen Skeggs }
520a34fb31SBen Skeggs 
530a34fb31SBen Skeggs static const struct nvkm_pci_func
540a34fb31SBen Skeggs nv40_pci_func = {
550a34fb31SBen Skeggs 	.rd32 = nv40_pci_rd32,
560a34fb31SBen Skeggs 	.wr08 = nv40_pci_wr08,
570a34fb31SBen Skeggs 	.wr32 = nv40_pci_wr32,
580a34fb31SBen Skeggs 	.msi_rearm = nv40_pci_msi_rearm,
590a34fb31SBen Skeggs };
600a34fb31SBen Skeggs 
610a34fb31SBen Skeggs int
nv40_pci_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_pci ** ppci)62*9b70cd54SBen Skeggs nv40_pci_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
63*9b70cd54SBen Skeggs 	     struct nvkm_pci **ppci)
640a34fb31SBen Skeggs {
65*9b70cd54SBen Skeggs 	return nvkm_pci_new_(&nv40_pci_func, device, type, inst, ppci);
660a34fb31SBen Skeggs }
67